I'm in need for a regular expression that will match a limited character set that has rules.
The rules are:
- 3 to 15 character long (inclusive) e.g. "abc" "abcdefghijklmno"
- Only characters A-Z 0-9 - _ . ( ) [ ] e.g. thats A-Z 0-9, dash, underscore, period, left & right round bracket, and left & right square bracket. (No spaces allowed)
- The string cannot start with anything other than A-Z or 0-9 e.g Match = "bob123[bob]" but not "[bob]bob123".
- The string cannot contain two adjacent punctuation marks (punctuation is dash, underscore, period, left/right round bracket and left/right square bracket).
So based on those, here a just a few examples of what the regular expression would match:
But it would not match:
Im developing this in C#.NET and I can get it to match the lenth and the A-Z 0-9 and special characters, however I do not know how to enforce the last two rules.
Any help would be greatly appreciated.