in reply to regex for multiple capture within boundary
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)},"
The Sidhekin proves Sidhe did it!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: regex for multiple capture within boundary
by ikegami (Patriarch) on Jul 14, 2006 at 22:10 UTC | |
|
Re^2: regex for multiple capture within boundary
by ikegami (Patriarch) on Jul 14, 2006 at 23:58 UTC |