Link to home
Start Free TrialLog in
Avatar of jl66
jl66Flag for United States of America

asked on

how to match/filter the lines in perl

Want to filter the lines formed by the 3 parts:
part1 part2 part3
separated by spaces and tabs.
part1 contains alphanumeric, (), -, and _
part2 and part3 are digits.
For example,
A1-(ABC)XX1_(C)DE10     1223345    323242
XX10_1(2)                             98765       67890
For only part2 and part3, it's something like
$_ =~ /^\d+\s+\d+$/
to filter it. How to do it if considering all 3 parts?
SOLUTION
Avatar of mrjoltcola
mrjoltcola
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
if you have to verify that it meets the exact requires you specified:
$_=~/^([0-9a-zA-Z\(\)\-_]+)\s(\d+)\s(\d+)/

Open in new window

Avatar of jl66

ASKER

mrjoltcola, I want to verify the data, so the inputs have to follow some patterns.
rcflyr, it did not work. I used the above two lines as an example.
Avatar of jl66

ASKER

continued --rcflyr, it did not work. I used the above two lines as an example. It gave two "bad" lines
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial