Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What's wrong with my regular expresion?

Status
Not open for further replies.

kobewins

Programmer
Dec 1, 2005
57
US
Hi,

I have a text input file (sam_rpt), containing data like:

-----------------
LOAD0007
RUN DATE: Dec 13, 2005 12:07:42
PRIMARY KEY
Error Text: 1, , 12, DOCDEA, PRACTITIONER_REGI ...
Error Text: 3, , 12, DOCDEA1, , PRACTITIONER_REG
RECORDS READ: 6 ACCEPTED: 2
---------------

I need to get each of the first number after 'Error Text: '. So far I have the follwing code, but doesn't work. Please help.

--------
#!/usr/bin/perl

my @list = `grep "Error Text:" sam_rpt`;

foreach $x (@list)
{
($line_num, $rest) =~ (/^Error Text: (d+)(.*)$/);
print "Line # = $line_num \n";
#print $x;
}
---------

Thanks
David



 
How about something like:
[tt]
foreach(@list)
{
/Error Text:\s*(\d+)/;
print "Line no. $1\n";
}
[/tt]
 
you have: (d+) literally means one or more d's

it should be: (\d+) which means one or more digits

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top