Here is the regular expression that I am trying to modify:
The client only wants the user to be able to enter a maximum of 2 of the same consecutive characters.
^[a-zA-Z0-9-().\&\@\?\""#,\+\''\s\/]{7,}$
Here is the regular expression that I am trying to modify:
The client only wants the user to be able to enter a maximum of 2 of the same consecutive characters.
^[a-zA-Z0-9-().\&\@\?\""#,\+\''\s\/]{7,}$
You can use a look-ahead assertion:
/^(?:([a-zA-Z0-9-().&@?"#,+'\s\/])(?!\1\1)){7,}$/
Here the negated look-ahead assertion (?!\1\1)
is tested for each character that is matched by ([a-zA-Z0-9-().&@?"#,+'\s\/])
. It looks at the next two following characters and tests if they are the same as the previously matched one. If this is not the case, the negated look-ahead assertion is fulfilled.