is there a possibility to return all the matches of a regexp? or in
other words is there a way to apply a block to all matches at once?
Something like String#gsub but where I can specifiy what to do with the
matches...
1. Look at String#scan
2. Look at String#gsub with the block form and use Regexp::last_match
(it's a thread-local value, IIRC).
-austin
···
On 12/11/06, Andi Schacke <memberships.andi@gmail.com> wrote:
is there a possibility to return all the matches of a regexp? or in
other words is there a way to apply a block to all matches at once?
Something like String#gsub but where I can specifiy what to do with the
matches...
is there a possibility to return all the matches of a regexp? or in
other words is there a way to apply a block to all matches at once?
Something like String#gsub but where I can specifiy what to do with the
matches...
is there a possibility to return all the matches of a regexp? or in
other words is there a way to apply a block to all matches at once?
Something like String#gsub but where I can specifiy what to do with the
matches...
What exactly do you want to do with matches?
robert
I'd like to build a small web-tool for myself to highlight all the
matches of a regexp against a specified string (e.g. the matches should
be in a different color). But I think I found a solution:
is there a possibility to return all the matches of a regexp? or in
other words is there a way to apply a block to all matches at once?
Something like String#gsub but where I can specifiy what to do with the
matches...
What exactly do you want to do with matches?
robert
I'd like to build a small web-tool for myself to highlight all the
matches of a regexp against a specified string (e.g. the matches should
be in a different color). But I think I found a solution:
I'd like to build a small web-tool for myself to highlight all the
matches of a regexp against a specified string (e.g. the matches should
be in a different color). But I think I found a solution: