magnetica2 Posted October 19, 2011 Share Posted October 19, 2011 Hi All Need a little help with my RegEx, I am half way there but can't figure out the last bit I want the Regex to match. 123-456-789 I don't mind how long the numbers are, but the dashes in the middle can only be 1 long My regex so far ([^-]([0-9]+[^-])) This matches 123-456-789 but will also match 123-456----789 I just need the Regex to only allow 1 dash in the middle Thanks for any help Link to comment https://forums.phpfreaks.com/topic/249390-need-help-with-simple-regex-pattern/ Share on other sites More sharing options...
JAY6390 Posted October 19, 2011 Share Posted October 19, 2011 [\d]+(-[\d]+)* Link to comment https://forums.phpfreaks.com/topic/249390-need-help-with-simple-regex-pattern/#findComment-1280504 Share on other sites More sharing options...
magnetica2 Posted October 19, 2011 Author Share Posted October 19, 2011 Like a dream thank you very much Link to comment https://forums.phpfreaks.com/topic/249390-need-help-with-simple-regex-pattern/#findComment-1280507 Share on other sites More sharing options...
JAY6390 Posted October 19, 2011 Share Posted October 19, 2011 cool no problem Link to comment https://forums.phpfreaks.com/topic/249390-need-help-with-simple-regex-pattern/#findComment-1280521 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.