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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions: Re: [KevinR] Help with an if regx statement: Edit Log



seahorse
Novice

Jan 30, 2007, 1:27 PM


Views: 9320
Re: [KevinR] Help with an if regx statement

Thanks for your respone KevinR, however $inbad3 fails (says it's good when it should be bad). Below is a better version of the program thus far so please ignore the 1st one. Set $test to any of the $in strings to see what is good or bad. What I have labeled 'stuff' and 'morestuff' can be any number of characters except [ or ] or , (comma) characters.

Also, another rule is that the $in strings cannot be modified to 'fix' the problem.

$inbad1 = "[0],[0,1],[1,0,3,5]";

$inbad2 = "[[0],[0,2]]";

$inbad3 = "[[0]stuff,morestuff[0,4]]";

$ingood1 = "[0][0,1,2][0,1]";

$ingood2 = "[0]stuff[0,1][1,0,2,5]";

$test = $inbad3;

if ($test =~ /\,/) {

# If there are , (comma) character(s) then they all must be located between a set of [ ] (bracket) characters.


if ($test =~ /\],\[/) { print "it's bad"; } else { print "it's good"; }


}



(This post was edited by seahorse on Jan 30, 2007, 1:32 PM)


Edit Log:
Post edited by seahorse (Novice) on Jan 30, 2007, 1:29 PM
Post edited by seahorse (Novice) on Jan 30, 2007, 1:30 PM
Post edited by seahorse (Novice) on Jan 30, 2007, 1:32 PM


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

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