in reply to How to write a regular expression to extract a number from an embedded string?

I think it's as easy as this:
$_="abcedf 5163 1234 5678 or 1234516323943293"; print "$1\n" while /(5163(?:\s*\d){8})/g;
  • Comment on Re: How to write a regular expression to extract a number from an embedded string?
  • Download Code

Replies are listed 'Best First'.
Re^2: How to write a regular expression to extract a number from an embedded string?
by davido (Cardinal) on Jul 28, 2004 at 20:32 UTC

    You're making the same mistake everyone else is making. He wants eight numeric digits after 5163, and wants to preserve whitespace in addition to the eight numeric digits. You're going to end up returning less than the eight numeric digits if the input string contains whitespace. That's not what his question asks.


    Dave