Reputation: 44066
Ok so i dont understand regex checker works in ruby
=~
1.9.2p290 :009 > url = "/myurl"
=> "/myurl"
1.9.2p290 :010 > url =~ %r{^/.*/found/\d+$}i
=> nil
1.9.2p290 :011 > url = "/myurl/found/1"
=> "/myurl/found/1"
1.9.2p290 :012 > url =~ %r{^/.*/found/\d+$}i
=> 0
It seems to return a value of something if found otherwise it returns nil ...but i dont know for sure ....where is the documentation for this anywhere...i tried to google for this and no luck at all...any help would be appreciated
Upvotes: 0
Views: 113
Reputation: 168081
When it matches, it returns the position of the beginning of the match. Otherwise, returns nil. The 0
in your last example means that the substring that matched the regex starts from position 0
of the original string.
Upvotes: 3