Thanks Darren...Show us your-Regex!
The place that I work uses what we call index numbers (they're not really numbers per se...) that are based on API numbers (which are usually numbers) for check shot velocity surveys. I'm working on a project that will validate these and I thought that it would be well suited for Regex since it's going to be text validation and there are rules in place for these Index “numbers”.
So first I go to www.regexlib.com and see what that might have to get those Regex juices flowin. Then I thought about the Regex that I need to write and wrote it out as the rules should apply:
- Start at the beginning of a string.
- Match exactly 2 digits.
- Match exactly 1 letter (uppercase).
- Match no less than 3 but no more than 4 digits.
- Optionally match 1 or 2 letters (uppercase).
- End of string.
So, I fired up Darren Neimke's RegexSnippets which I have sitting in my C:\Tools folder for just such an occasion, and this is what I came up with:
^\d{2}[A-Z]{1}\d{3,4}([A-Z]{1,2})?$
And much to my surprise it worked the first time running! Very nice. Plus, I was able to save the regex for later using Darren's cool little utility. Added bonus: there was already one expression (8PointFloat) that I needed for a different area. Thanks Darren!