I've been trying to resolve this all day.
Here are the requirements:
- I want to match strings that optionally starts with " _ "
- Should then continue with one or more case-insensitive alphabet
- Should then contain an optional " _ " or " - " followed by case-insensitive alphanumeric characters (This step should match at lease once).
- Then it may optionally end with " _ "
The above requirements are not a problem 'cos I achieved that with:
/_?[A-Za-z]([-_]?[A-Za-z0-9])+_?/
The above RegEx matches:
- user_
- usEr-nAme
- uSer_naMe-Two_
- _Userna-Me_tHree-and-four
THE PROBLEM
How do I make it match only 6 to 25 characters?
I Tried
/(_?[A-Za-z]([-_]?[A-Za-z0-9])+_?){6,25}/
but it still matches string less than 6 like Use-r