in reply to Re^2: How to write a regular expression to extract a number from an embedded string?
in thread How to write a regular expression to extract a number from an embedded string?
That is, exactly 8 occurences of (any number of spaces followed by) a single digit. What my code did do wrong is that it assigned $numbers to the result of the check in scalar context, not in list context. But(?:\s*\d){8}
will work. If you don't believe me, test it out.my ($numbers) = $string =~ /(5163(?:\s*\d){8})/;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: How to write a regular expression to extract a number from an embedded string?
by davido (Cardinal) on Jul 28, 2004 at 20:45 UTC |