Perl program need in regular expression

B

Benson

I want a program can read a log file and capture the character seg=9543
The file log line like this

"Webtrends=219.65.94.207.13841063300606-888510000; SESSION=%7EgrfwSipoiI; seg=9543"

Capture character set "seg=9543"
get the value of number 9543 to a valuable. for calculation.

How to use regular expression get the value number 9543?
 
L

Lao Coon

(e-mail address removed) (Benson) wrote in
I want a program can read a log file and capture the character
seg=9543 The file log line like this

"Webtrends=219.65.94.207.13841063300606-888510000;
SESSION=%7EgrfwSipoiI; seg=9543"

Capture character set "seg=9543"
get the value of number 9543 to a valuable. for calculation.

How to use regular expression get the value number 9543?

Read perldoc perlre

e.g.

my $value, $string = "Webtrends=219.65.94.207.13841063300606-888510000;
SESSION=%7EgrfwSipoiI; seg=9543";

if ($string =~ /seg=(\d+)/) {
$value = $1;
}


Lao
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top