CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Regular Expressions:
how to match complete string vs regex


New User

Mar 5, 2008, 1:30 PM

Post #1 of 2 (8085 views)
how to match complete string vs regex Can't Post

Hi all, i need little help with the following:
Say i expect my string of text to be of a certain format:
like for example:

"ABCDE ABC123 ABCfdfdf"

In other words the 1st word can only contain uppercase letters, the 2nd word can contain uppercase and digits and the 3rd word can contain uppercase and smallcase letters. Now what i have achieved is the matching against individual components of the string in question. But what i need is to match the whole thing, in other words if i have something like that as input:

"abcde ABC123 ABCfdfdf"

it should not match because the 1st word has small case letters, even though there is a match in the other 2 words.

Thanks in advance


Mar 5, 2008, 1:42 PM

Post #2 of 2 (8080 views)
Re: [dimaash] how to match complete string vs regex [In reply to] Can't Post

Next time please post your existing code, it helps to see what you have tried. You did not mention if the length of each "word" is also important, so I assume it's not:

if ($foo =~ /^[A-Z]+\s+[A-Z0-9]+\s+[a-zA-Z]+$/) { 
print "It's good";



Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives