View Single Post
  #7 (permalink)  
Old 04-23-2008, 08:27 PM
shaalini shaalini is offline
D-Web Analyst
 
Join Date: Apr 2007
Posts: 342
shaalini is on a distinguished road
Default 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...
Reply With Quote