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

No members online now.

Forum statistics

Threads
474,169
Messages
2,570,919
Members
47,460
Latest member
eibafima

Latest Threads

Top