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:
- bob123[bob]
- bob[123]BOB
- 123(bob_HI
- B12_b(0]b
But it would not match:
- [bob]123[bob]
- (bob)123bob
- .bob123
- _bob123
- bob{(123
- b_{bob}123
- bob@home
- bob$ayshello
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. 