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 Link to comment https://forums.phpfreaks.com/topic/83337-solved-preg/ 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"; } ?> Link to comment https://forums.phpfreaks.com/topic/83337-solved-preg/#findComment-423980 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 Link to comment https://forums.phpfreaks.com/topic/83337-solved-preg/#findComment-423987 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.