
seahorse
Novice
Jan 30, 2007, 3:30 PM
Views: 3400
|
|
Re: [KevinR] Help with an if regx statement
|
|
|
Thanks for the 1-liner. Sorry about the confusion on stuff and morestuff. I know I wasn't real clear on what I wanted with them. Yours is close however there are still some cases where it fails, namely $inbad4 & $inbad5. Then there is the comma at the end and the [stuff,morestuff[ case. How would you fit these into your 1-liner? BTW, I also found ProBulletin's solution fails $inbad6 $inbad6 = "[0]stuff[0,1][1,0,2,5][stuff,morestuff["; $inbad1 = "[0],[0,1],[1,0,3,5]"; $inbad2 = "[[0],[0,2]]"; $inbad3 = "[[0]stuff,morestuff[0,4]]"; $inbad4 = ",[0][0,1,2][0,1]"; $inbad5 = "[0]stuff[0,1][1,0,2,5]]stuff,morestuff]"; $ingood1 = "[0][0,1,2][0,1]"; $ingood2 = "[0]stuff[0,1][1,0,2,5]"; for ($inbad1,$inbad2,$inbad3,$inbad4,$inbad5,$ingood1,$ingood2) { if (/\](\w*,\w*)+\[/) { print "$_: it's bad\n"; } else { print "$_: it's good\n"; } }
(This post was edited by seahorse on Jan 30, 2007, 3:44 PM)
|