asmith Posted December 3, 2007 Share Posted December 3, 2007 why i can't get this working ? i want to search , the sentese must be start with a number , then must have --- then must contain letters and numbers . but this code accepts -- instead of ---, and if i don't start with a number it accept that too , please help ! <? $a = ---fdfg if (preg_match("/^[0-9]*---*[0-9a-zA-Z]/",$a)) {echo "yes";} else {echo "no";} ?> Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted December 3, 2007 Share Posted December 3, 2007 your regular expression should be if (preg_match("/^[0-9]+---+[0-9a-zA-Z]+/",$a)) Quote Link to comment Share on other sites More sharing options...
asmith Posted December 3, 2007 Author Share Posted December 3, 2007 yea, works !thanks ! anyway what does + do ? Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted December 3, 2007 Share Posted December 3, 2007 "+" matches once or more times so there has to be a occurance, "*" matches 0 or more so it will even match when there is no occurances Quote Link to comment Share on other sites More sharing options...
asmith Posted December 3, 2007 Author Share Posted December 3, 2007 thanks a lot ! Quote Link to comment 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.