in reply to Re: Regex: plucking numbers from a large string
in thread Regex: plucking numbers from a large string
Or the ever handy \G zero-width assertion
Which is great if your data is "Tel: 061Tel: 062Tel: 063", 'cause you'd have to use something to match stuff in between, and there's probably a better solution to this than using .*.
You can use m//g in list context, and get a list of matches (or a list of captures if you use them):
If you don't need the list, you can of course use the match itself as for's expression.my @extensions = $large_string =~ /Tel: 06(\d+)/g; my %extension; $extension{$_}++ for @extensions;
- Yes, I reinvent wheels.
- Spam: Visit eurotraQ.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Watch $1 vs. $_ in for loops...
by RMGir (Prior) on May 01, 2002 at 20:12 UTC |