asmith Posted December 27, 2007 Share Posted December 27, 2007 i want to verify a sentence like : a,r,h,f,bb,r,t,s,hth letters or words between "," my current code is : if (!preg_match("/^([a-z]+,*)+$/",$a)) { echo "no"; } but it allows 2 or more "," and i want to end with word or letter, not end with "," how can i fix it ? thanks Quote Link to comment Share on other sites More sharing options...
rea|and Posted December 27, 2007 Share Posted December 27, 2007 Try this code: <?php if (!preg_match("/^[a-z]+(,[a-z]+)+$/",$a)) { echo "no"; } ?> Quote Link to comment Share on other sites More sharing options...
asmith Posted December 27, 2007 Author Share Posted December 27, 2007 it should be this : <?php if (!preg_match("/^[a-z]+(,[a-z]+)*$/",$a)) { echo "no"; } ?> thanks for taking time 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.