mdp716 Posted November 5, 2013 Share Posted November 5, 2013 Hello - I think StringRegExp() is going to give me a headace. What I am looking to do is test a string which should match the following: 1. Will always be 8 characters long 2. Will always start with "P" 3. 2nd, 3rd, and 4th Characters will always be Alpha (from 'A' to 'Z') 4. 5th, 6th, 7th, and 8th Characters will always be hexidecimal (from '0' through '9' or 'A' to 'F') The test string will already be all caps due to the Edit box style settings so no need to worry about lower case. So basically, I am looking for an expression that will identify if the above rules are met in the tested string. I know this should not be that hard, but I've spent a few hours on this already and haven't found the expression that will not allow errors to slip by. Any one of you wizards out there have a quick answer to this? Thanks in advance. Link to comment Share on other sites More sharing options...
mrider Posted November 5, 2013 Share Posted November 5, 2013 I'm thinking something along the lines of StringRegExp($your_string, "^P[A-Z]{3}[0-9A-F]{4}$") should work... mdp716 1 How's my riding? Dial 1-800-Wait-There Trying to use a computer with McAfee installed is like trying to read a book at a rock concert. Link to comment Share on other sites More sharing options...
mdp716 Posted November 6, 2013 Author Share Posted November 6, 2013 I'm thinking something along the lines of StringRegExp($your_string, "^P[A-Z]{3}[0-9A-F]{4}$") should work... Well that sure looks right - no doubt the problem is the solution was far simpler than I was thinking. Will test it out tomorrow and let you know, thanks for this so much. Link to comment Share on other sites More sharing options...
mdp716 Posted November 6, 2013 Author Share Posted November 6, 2013 I'm thinking something along the lines of StringRegExp($your_string, "^P[A-Z]{3}[0-9A-F]{4}$") should work... That worked flawlessly - thank you so much for you help. Link to comment Share on other sites More sharing options...
mrider Posted November 6, 2013 Share Posted November 6, 2013 No problem. Just a parting shot: That regex precisely matches what you specified. So for example, the first characters will fail on non-ASCII upper case letters (e.g. Ä). It will also fail if you receive lower case hex characters. Just so you know. How's my riding? Dial 1-800-Wait-There Trying to use a computer with McAfee installed is like trying to read a book at a rock concert. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now