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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

regular expression

Status
Not open for further replies.

Yarka

Technical User
Joined
Jan 14, 2007
Messages
192
Location
ES
hi,
i have an script perl as:

my($a)= "a" ;
my($b)="b";

if(/^(\d+)\t$a\t.*?\t$b.\t([^\t]+)\t2.3.22 aco/){
...
}

My input file lines is style as:

58702 a 00:13 b2 00:02 0EP:D7 33 1,0 t2.3.22 aco 55.33.kk

...
I want to check this file with my script, but not detected regular expression. Can anybody help me?

Thanks.
 
Well, maybe I don't explain very well:
I have a large file with lines of style as
...
58702 a 00:13 b2 00:02 0EP:D7 33 1,0 t2.3.22 aco 55.33.kk

58 cc 00:13 b2 00:02 0EP:D7 555 1,0 t2.3.22 aco 55.33.kk

689 a 00:13 b1 00:02 0EP:D7 969 1,0 t2.3.22 aco 55.33.kk

58702 a 00:13 b2 00:02 0EP:D7 969 1,0 t2.3.22 aco 55.33.kss
...

I only want to work the lines with pattern a, b and t2.3.22 aco. On the before example, I only have to choose 1, 2 and 3 lines.

For this reason, I have this conditional into my script:
f(/^(\d+)\t$a\t.*?\t$b.\t([^\t]+)\t2.3.22 aco/){
...
}
but, this not select any lines of my input file.
 
>/^(\d+)\t$a\t.*?\t$b.\t([^\t]+)\t2.3.22 aco/
Try this?
[tt]/^\d+\s+$a\s+.*?\s+$b\d\s+.*?t2\.3\.22 aco.*?$/[/tt]
 
unless you have to validate the entire line you can do a simpler check to get the lines you want:

Code:
if (/\sa\s/ && /\sb\S\s/ && /\st2.3.22 aco\s/) {
   print $_;
}

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top