RobertP Posted June 19, 2012 Share Posted June 19, 2012 i need to make sure my string does NOT end with a dash '-'. /^&[a-zA-Z0-9-]{3,}$/ Any help would be greatly appreciated! Link to comment https://forums.phpfreaks.com/topic/264459-optional-ends-with/ Share on other sites More sharing options...
Andy-H Posted June 19, 2012 Share Posted June 19, 2012 /^&[a-zA-Z0-9-]{3,}[^-]$/ //Edit If you meant ends with an alpha-numeric character, this rule matches '&' followed by AT LEAST 2 alphanumeric and hyphen characters, followed by one or more alphanumeric character /^&[a-zA-Z0-9-]{2,}[a-zA-Z0-9]+$/ Link to comment https://forums.phpfreaks.com/topic/264459-optional-ends-with/#findComment-1355267 Share on other sites More sharing options...
RobertP Posted June 19, 2012 Author Share Posted June 19, 2012 /^&[a-zA-Z0-9-]{3,}[^-]$/ Thank you so much.. i was playing around with this :S /^&[a-zA-Z0-9-](?!-){3,}$/ Link to comment https://forums.phpfreaks.com/topic/264459-optional-ends-with/#findComment-1355270 Share on other sites More sharing options...
Andy-H Posted June 19, 2012 Share Posted June 19, 2012 Please see my edit, the patten you quoted will match & followed by 3 or more alpha-numeric / hyphen characters followed by ANYTHING but a hyphen i.e. &75gg45g---54g-g54g% Link to comment https://forums.phpfreaks.com/topic/264459-optional-ends-with/#findComment-1355280 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.