in reply to How to write a regular expression to extract a number from an embedded string?
Whoops. I misread the question. This finds the key tag "5163" and then finds the next eight numbers with optional interspersed whitespace.
my ($number) = $str =~ /5163((?:\s*\d){8})/# Extract all numbers and whitespace including punctuation frequently +significant to numbers my $numbers = join ' ', $str =~ /([\d .-+]+)/g; # Less whitespace $numbers =~ s/(\s)\1+/$1/g;
|
|---|