Matching pattern in PERL

Hello,
 I need to verify a string from the command line in a PERL script.  I  need to make sure that the string has the following format:

ABS <A-Z><A-Z><A-Z> <0-9>.<0-9>.<0-9> <A-Z><number> <A-Z><number>

here is a sample:

ABS MSI 9.8.5 A209 B203
ABS HGF 9.8.5 A1234 B6456

i.e. of not valid strings:

SABS MSI 9.8.5 A209 B203
ABS HGF 19.8.5 A1234 B6456
ABS MSI 9.84.5 A209 B203
ABS HGF 9.85.5 A1234 B6456
ABS MSI 9.8.5 A209 B203D
ABS HGF 9.8.5 AB1234 B6456

(in words: ABS 3 letters, space, number.number.number letternumber letternumber)
String needs to start with ABS, then the rest of the sequence.

This is what I was trying but it is not working:
($LABEL =~ /^ABS [A-Z][A-Z][A-Z] [0-9]\.[0-9]\.[0-9] A[0-9][0-9][0-9] B[0-9][0-9][0-9]/))

Thanks
atoncelliAsked:
Who is Participating?
 
ozoCommented:
/^ABS [A-Z][A-Z][A-Z] [0-9]\.[0-9]\.[0-9] A[0-9]+ B[0-9]+$/
0
 
atoncelliAuthor Commented:
That works! Thanks

What does the
+$
do?
0
 
Adam314Commented:
The + means one or more of what is before it.
The $ at the end means end of line (a $ in the middle will be interpreted as a variable name).
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
Adam314Commented:
ozo had answered your original question... the points should have gone to him (or at least a split)
0
 
atoncelliAuthor Commented:
Oops!  I didn't noticed.  Very sorry about that.
 Is there a way to go back and fix it?
0
 
Adam314Commented:
You'll have to post a question in community support referring to this question.  Explain what you want, and they will help you.
0
 
atoncelliAuthor Commented:
I did that.
Thanks
0
 
ozoCommented:
see
perldoc perlre
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.