“tttttattttt”.match(/ttt(?=a)/) # Rubular: ttt(?=a)
=> [“ttt”]
“tttttattttt”.match(/(?=a)ttt/) # Rubular: (?=a)ttt
=> nil
Why? And how can I get this effect?
“tttttattttt”.match(/ttt(?=a)/) # Rubular: ttt(?=a)
=> [“ttt”]
“tttttattttt”.match(/(?=a)ttt/) # Rubular: (?=a)ttt
=> nil
Why? And how can I get this effect?
On 04/09/2010 10:40 AM, Nathan wrote:
“tttttattttt”.match(/ttt(?=a)/) # Rubular: ttt(?=a)
=> [“ttt”]
“tttttattttt”.match(/(?=a)ttt/) # Rubular: (?=a)ttt
=> nilWhy? And how can I get this effect?
It seems you have just demonstrated how to get the effect you described.
For more info:
http://www.geocities.jp/kosako3/oniguruma/doc/RE.txt
Note: you need Ruby 1.9.
Kind regards
robert
Ah (?<=a)ttt is what I was after. Thanks for the link.
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