Re: Ruby Regular Expression using the .new method for the Regexp class.
Whenever a match is found, a number of variables are created by Ruby.
Here are some examples with added details:
puts “Characters before the match : #{$`}”
puts “Matched characters : #{$&}”
or
puts “Matched characters : #{$~}”
puts “Characters after the match : #{$’}”
puts “Tird part of the match : #{$3}”
__________________ Shaalini.S Be the Best of Whatever you are... |