regexp which matches nothing?

J

Joao Silva

How i can construct regexp, which will always matches nothing?

For example:

"xxxxxxx".match /my_special_regexp/
=> should be ALWAYS nil
 
7

7stud --

Joao said:
How i can construct regexp, which will always matches nothing?

For example:

"xxxxxxx".match /my_special_regexp/
=> should be ALWAYS nil

How about:

re = /$a^/
 
K

Kilian Verhetsel

Why do you want to have a such regex ?

Anyway, it seems that /^$a/ will never match with any string.

"a".match /^$a/
=> nil
"".match /^$a/
=> nil
"a ".match /^$a/
=> nil
 
R

Ralf Mueller

Joao said:
How i can construct regexp, which will always matches nothing?

For example:

"xxxxxxx".match /my_special_regexp/
=> should be ALWAYS nil
not sure, but something that should always be nil .... what about the constant 'nil' ;)
 
R

Ralf Mueller

Joao said:
How i can construct regexp, which will always matches nothing?

For example:

"xxxxxxx".match /my_special_regexp/
=> should be ALWAYS nil

Just out of curiosity: Why do you use a method call, when you expect a constant?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top