I want to mimic
while($string=~/($regular_expression)/g){
print $1."\n";
}
of Perl in Ruby.
Is there a way to do that in Ruby (e.g. print something per match)?
I want to mimic
while($string=~/($regular_expression)/g){
print $1."\n";
}
of Perl in Ruby.
Is there a way to do that in Ruby (e.g. print something per match)?
To print each match in a string:
string = 'abc'
regex = /./
string.scan(regex) {|x| puts x}
Output is:
a
b
c