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

Here's my go.
#!/bin/perl5 use strict; use warnings; my @array = ( 'abcedf 5163 1234 5678', '1234516323943293' ); for ( @array ){ /(5163.*)/; print "$1\n"; }
produces:
5163 1234 5678 516323943293

Update: Whoops. It looks as though I didn't read the question properly. See pbeckingham comment below.

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

    Please be aware that your suggestion of using

    .*
    will greedily include everything to the end of the string. The OP specifically states 8 digits, with possible whitespace breaking the digits into groups of 4.

    While your suggestion works on your test data, it will not work on certain other data.