nadeemshafi Posted November 17, 2010 Share Posted November 17, 2010 hi i have this regex /^([a-zA-Z0-9_\-\.\']+)$/ it allows letters and number and single quotes, i want to limit the ammount of single quotes to {0,1} but i cant seem to get the quantifier in the right place. Any help appreciated. Link to comment https://forums.phpfreaks.com/topic/218965-using-a-quantifier-inside-a-character-set/ Share on other sites More sharing options...
JAY6390 Posted November 17, 2010 Share Posted November 17, 2010 Can't really do it like that as far as I'm aware. one solution is the following /^([\w\.-]*'?[\w\.-]*)$/ Note that \w matches a-zA-Z0-9 and \_ Link to comment https://forums.phpfreaks.com/topic/218965-using-a-quantifier-inside-a-character-set/#findComment-1135541 Share on other sites More sharing options...
nadeemshafi Posted November 17, 2010 Author Share Posted November 17, 2010 Thanks for your help, thats perfect Link to comment https://forums.phpfreaks.com/topic/218965-using-a-quantifier-inside-a-character-set/#findComment-1135582 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.