I wrote the following expression, but I had a problem:
^[^\.]*[a-zA-Z]+$
According to the above expression df45543is invalid, but I want to allow such a string. Only one character of the alphabet is required, and a period is not allowed. All other characters are allowed.
df45543
You need to use lookahead to force a single alphabet:
^(?=.*?[a-zA-Z])[^.]+$
(?=.*?[a-zA-Z]) - This is a positive look that guarantees that at least one alphabet will be at the entrance.
(?=.*?[a-zA-Z])
Just add numbers as valid characters:
^[^\.]*[a-zA-Z0-9]+$
Watch the demo
1 , lookaheads:
^(?!.*\.)(?=.*[a-zA-Z]).+$
(?!.*\.) , (?=.*[a-zA-Z]) .
(?!.*\.)
(?=.*[a-zA-Z])
- .
^(?!\.)(?=.*[a-zA-Z]).+$
:
^[^.a-z]*[a-z][^.]*$
( , , A-Z )
A-Z
, ^[^.]* ,
^[^.]*
^[^.]*[A-Za-z]+[^.]*$