How i can construct regexp, which will always matches nothing?
For example:
“xxxxxxx”.match /my_special_regexp/
=> should be ALWAYS nil
How i can construct regexp, which will always matches nothing?
For example:
“xxxxxxx”.match /my_special_regexp/
=> should be ALWAYS nil
Joao S. wrote:
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^/
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
7stud – wrote:
Joao S. wrote:
How i can construct regexp, which will always matches nothing?
For example:
“xxxxxxx”.match /my_special_regexp/
=> should be ALWAYS nilHow about:
re = /$a^/
I guess that could be made even simpler:
re = /a^/
Joao S. wrote:
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’
Joao S. wrote:
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?
7stud – wrote:
7stud – wrote:
Joao S. wrote:
How i can construct regexp, which will always matches nothing?
For example:
“xxxxxxx”.match /my_special_regexp/
=> should be ALWAYS nilHow about:
re = /$a^/
I guess that could be made even simpler:
re = /a^/
…and probably more efficient:
re = /a\A/
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs