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: [seahorse] Help with an if regx statement: Edit Log



ProBulletin
Novice

Jan 30, 2007, 1:53 PM


Views: 8712
Re: [seahorse] Help with an if regx statement

There are better ways than this but it is one way at least. Unless I've overlooked something simple it was trickier than it first appeared.


Code
   
my $open = 0;
LOOP: while ($test =~ /(.)/g) {
my $char = $1;
if ($char eq '[' or $char eq ']') {
$open = $char eq '[' ? 1 : 0;
}
else {
if ($char eq ',' and $open == 0) {
print "INVALID";
last LOOP;
}
}
}



Regards,
Paul Wilson
ProBulletin Board: http://www.probulletin.com/


(This post was edited by ProBulletin on Jan 30, 2007, 1:53 PM)


Edit Log:
Post edited by ProBulletin (Novice) on Jan 30, 2007, 1:53 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