shadiadiph Posted June 27, 2010 Share Posted June 27, 2010 Hi any Ideas how I can include a comma in this regex? /^[a-zA-Z\.\-\'\s]*$/ Link to comment https://forums.phpfreaks.com/topic/206012-including-comma-in-regex/ Share on other sites More sharing options...
Alex Posted June 27, 2010 Share Posted June 27, 2010 Just add a comma to the class: /^[a-zA-Z\.\-\'\s,]*$/ Link to comment https://forums.phpfreaks.com/topic/206012-including-comma-in-regex/#findComment-1077989 Share on other sites More sharing options...
ZachMEdwards Posted June 28, 2010 Share Posted June 28, 2010 For the record, when you have a character list, you don't need to escape characters like "." '/^[a-zA-Z.\-\'\s]*$/' Link to comment https://forums.phpfreaks.com/topic/206012-including-comma-in-regex/#findComment-1078058 Share on other sites More sharing options...
salathe Posted June 28, 2010 Share Posted June 28, 2010 Why not go the whole hog, if you're wanting to remove unnecessary escaping? "/^[a-z\s'.-]*$/i" Link to comment https://forums.phpfreaks.com/topic/206012-including-comma-in-regex/#findComment-1078080 Share on other sites More sharing options...
shadiadiph Posted June 28, 2010 Author Share Posted June 28, 2010 thanks guys Link to comment https://forums.phpfreaks.com/topic/206012-including-comma-in-regex/#findComment-1078110 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.