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

ProBulletin
Novice
Jan 31, 2007, 2:39 AM
Views: 3329
|
|
Re: [seahorse] Help with an if regx statement
|
|
|
Try: my $open = 0; my $comma = 0; LOOP: while ($test =~ /(.)/g) { my $char = $1; if ($char eq '[' or $char eq ']') { $open = $char eq '[' ? 1 : 0; $comma = 0 if ($char = ']'); } else { if ($char eq ',' and $open == 0) { print "INVALID"; last LOOP; } elsif ($char eq ',' and $open == 1) { $comma = 1; } } } print "INVALID" if ($open and $comma); Regards, Paul Wilson ProBulletin Board: http://www.probulletin.com/
(This post was edited by ProBulletin on Feb 1, 2007, 5:10 PM)
|
|
|
Edit Log:
|
|
Post edited by ProBulletin
(Novice) on Jan 31, 2007, 2:42 AM
|
|
Post edited by ProBulletin
(Novice) on Feb 1, 2007, 5:10 PM
|
|
Post edited by ProBulletin
(Novice) on Feb 1, 2007, 5:10 PM
|
|
|  |