Displaying 1 result from an estimated 1 matches for "shotshot".
Did you mean:
hotshot
2012 Apr 23
4
Multiple regex match in the same line
Hi,
Could somebody please show me a way to find, and display multiple
regex matches in the same line?
Like this:
test_string = "I shot the Sherrif but I didn''t shot the Deputy."
# The word I would like to find is the "shot" and displayed like
"shotshot" or like each match could go into a new #line like:
"shot"
"shot"
# Some ways I tried:
regex = /shot/ =~ test_string
puts $& ------------> # would only match the
first match
regex = /(shot)*/ =~ test_string
puts $&...