Hello,
I'm using flex and bison to check the correctness of a username, so I have this regexp:
Code:
[A-za-z0-9]+([\.\-]?[A-Za-z0-9]+)*
This works ok for me: usernames start with a letter or number and can have '.' and '-' surrounded by at least one letter or number.
But now, I want to set a minimum and a maximum length of the username, I tried:
Code:
([A-za-z0-9]+([\.\-][A-Za-z0-9]+)*){3,22}
But this doesn't work, because it counts the number of times that the regexp is applied and not count the number of characters of the array.
Is there a way to apply two regexp at same time? like an "and" operator, if so, I could use something like:
Code:
[A-za-z0-9]+([\.\-]?[A-Za-z0-9]+)* AND .{3,22}
Or is there a way to count total characters of an input and apply a regexp at same time?
I think it must be easy to do, but by now my solution is to first check length with strlen and then check correctness using flex.
One link to a webpage lighting the solution will be ok, you don't need to give me the correct regexp.
Thanks in advance.