Next | Regular Expression Mastery | 91 |
/(?:(\d*)\s*)+/
Here's a FAQ:
If you try to match 12 34 56, only the 56 goes into $1.
Why? Isn't the + supposed to `repeat'?
What does it do?
Start copying, copy the 12 into $1, stop copying, repeat
Start copying, copy the 34 into $1, stop copying, repeat
Start copying, copy the 56 into $1, stop copying, end of string
End result: Only 56 is in $1.
Solutions:
Use split
Use m//g (coming up)
Next | Copyright © 2002 M. J. Dominus |