Syntactic Confectionery Delight | |
PerlMonks |
Re: regex for multiple capture within boundaryby Sidhekin (Priest) |
on Jul 14, 2006 at 21:58 UTC ( [id://561346]=note: print w/replies, xml ) | Need Help?? |
I want a single regex that grabs all the number characters between the spaces Extreme regexing? I cannot resist such a question. This ought to do it: @nums = $x =~ /(?:^\S*\s+|\G)[^\s\d]*(\d+)/g;However, if it does not absolutely have to be a single regex, I suspect the maintainer will prefer one of ikegami's solutions. :-) Update: I've been out-extremed! Not perhaps by the first of ikegami's latter solutions, which after all is straight-forward, and probably as maintainable as mine, but certainly by the second. It took me three attempts just to read it: My eyes glazed over twice! ... what's with the local *nums; though? Yet another update: Ah. Considerate of you. :-)
print "Just another Perl ${\(trickster and hacker)},"
In Section
Seekers of Perl Wisdom
|
|