I am trying to match some bbcode in the form of [quota=234] But can't seem to get it to work what I have so far is: if(preg_match("/\[quota=[0-9]\]/i",$string)){ //do stuff } Code (markup): but it is not working.....somehow I need to escape the [ brackets. An Idea s to how I can accomplish this?
<?php $string = "[quota=123456]This is our test string[/quota]"; if(preg_match("/\[quota=(.*)\]/i",$string)){ echo "Match Found"; }else{ echo "No Match"; } ?> PHP:
thanks MyVodaPhone ...it works perfectly. Can you tell me why the change to (.*) makes it work? When I do this preg_match("/quota=[0-9]/i",$string) it works for matching quota=123 But why not when I try [quota123 and the outer brakets....but your works with the change to (.*). Glad your version works just curious why mine didn't so I can learn Thanks for your help!
Well your initial search was including the [brackets] so I figured as long as we had an [opening and closing] bracket it didn't mater what quota was equalled to. If that's a problem let us know....
I guess I need to read up on REGEXP more because I still don't get it Anyway thanks for your help.... your solution is working excellent for what I need. Thanks again.