bigD Posted January 16, 2011 Share Posted January 16, 2011 OK, I am officially stumped. I am trying to match a '[]' at the end of a string. Using $ to anchor doesn't work, nor does \z. $name = "cities[]"; if (preg_match("/\[\]\z/", $name)) { // why do I net get in here?? } Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/224645-stumped-with-preg_match-call/ Share on other sites More sharing options...
requinix Posted January 16, 2011 Share Posted January 16, 2011 Works for me. Is that your actual code or did you try to simplify it? Quote Link to comment https://forums.phpfreaks.com/topic/224645-stumped-with-preg_match-call/#findComment-1160387 Share on other sites More sharing options...
bigD Posted January 16, 2011 Author Share Posted January 16, 2011 Works for me. Is that your actual code or did you try to simplify it? That is my actual code, except for hardcoding $name, which I output on debug, and it is correct... Quote Link to comment https://forums.phpfreaks.com/topic/224645-stumped-with-preg_match-call/#findComment-1160391 Share on other sites More sharing options...
requinix Posted January 16, 2011 Share Posted January 16, 2011 And you're sure it's correct? Doesn't have spaces or newlines at the end? preg_match("/\[\]\z/", trim($name)) Quote Link to comment https://forums.phpfreaks.com/topic/224645-stumped-with-preg_match-call/#findComment-1160394 Share on other sites More sharing options...
bigD Posted January 16, 2011 Author Share Posted January 16, 2011 And you're sure it's correct? Doesn't have spaces or newlines at the end? preg_match("/\[\]\z/", trim($name)) OK, it was correct. I was getting stale data from a mentally challenged programmer. All is well. How do I close/mark solved this thread? Quote Link to comment https://forums.phpfreaks.com/topic/224645-stumped-with-preg_match-call/#findComment-1160401 Share on other sites More sharing options...
requinix Posted January 16, 2011 Share Posted January 16, 2011 I honestly don't know. Haven't asked a question on this forum yet... But http://www.phpfreaks.com/forums/index.php/topic,118755.0.html Please mark your threads as "solved" using the link at the bottom of the thread. It'll help everyone to know which threads still need to be looked at! Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/224645-stumped-with-preg_match-call/#findComment-1160410 Share on other sites More sharing options...
Pikachu2000 Posted January 16, 2011 Share Posted January 16, 2011 It's the green button that says 'Mark Solved' Quote Link to comment https://forums.phpfreaks.com/topic/224645-stumped-with-preg_match-call/#findComment-1160443 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.