jordanwb Posted September 14, 2007 Share Posted September 14, 2007 A particular value is passed through GET in the particular format: (a-z)-(0-9), Example: nid-7 eid-24 Would this pattern work: ^([a-z]\-[0-9])*$ Quote Link to comment Share on other sites More sharing options...
effigy Posted September 14, 2007 Share Posted September 14, 2007 No; without a quantifier a character class matches only one character. Also, there is no need to escape the hyphen or place a quantifier on the grouping. What is the maximum number of letters and digits you're expecting? Quote Link to comment Share on other sites More sharing options...
jordanwb Posted September 14, 2007 Author Share Posted September 14, 2007 Really a maximum of 10 letters and there may be a unlimited number of numbers. Quote Link to comment Share on other sites More sharing options...
effigy Posted September 14, 2007 Share Posted September 14, 2007 This will require one to ten lowercase letters, followed by a hyphen, followed by one or more digits: /\A[a-z]{1,10}-\d+\z/ Quote Link to comment Share on other sites More sharing options...
jordanwb Posted September 14, 2007 Author Share Posted September 14, 2007 Okay thanks. Quote Link to comment Share on other sites More sharing options...
jordanwb Posted September 14, 2007 Author Share Posted September 14, 2007 I tried it and it didn't work if (!eregi ('/\A[a-z]{1,10}-\d+\z/', 'nid-1')) { print "Failed"; } it outputed Failed everytime. I could try using explode, split the 'nid' and the number apart, then compare. Quote Link to comment Share on other sites More sharing options...
effigy Posted September 14, 2007 Share Posted September 14, 2007 You need to use preg_match; it's a PCRE pattern, not an EREG pattern. Quote Link to comment Share on other sites More sharing options...
jordanwb Posted September 14, 2007 Author Share Posted September 14, 2007 I was not aware there was a difference. Now I do. It works, Thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.