How do match a number using regular expressions in Perl?

jay28lee
jay28lee used Ask the Experts™
on
this is rather a quick question.

$line = "some other html <b>13579</b> some other html";

i would like to extract the 13579 out of  this line into a variable.

how can this be done?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
$line =~ /<b>(\d+)<\/b>/;

match = $1;
Sorry:


$line =~ /<b>(\d+)<\/b>/;

$match = $1;

Open in new window

Or in one line

my ($match) = $line =~ /<b>(\d+)<\/b>/;

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial