Regular Expression, ([a-z] [A-Z] [0-9]) represents three characters, but ([a-zA-Z0-9 _-]) Why is there no length limit? Can abc be used, or can abcdef be used?
Regular Expression, ([a-z] [A-Z] [0-9]) represents three characters, but ([a-zA-Z0-9 _-]) Why is there no length limit? Can abc be used, or can abcdef be used?
Reply content:
Regular Expression, ([a-z] [A-Z] [0-9]) represents three characters, but ([a-zA-Z0-9 _-]) Why is there no length limit? Can abc be used, or can abcdef be used?
In the original po Image
Used/[a-zA-Z0-9]@gmail\.com/i
Matching2abcDEF123@gmail.com
Because the regular expression does not match the beginning or end of a string^
And$
So it is equivalent to: only matching in the string3@gmail.com
Part
Match the regular expression of the complete email string:
/^[a-z0-9_-]+@[a-z0-9_-]+\.[a-z]+$/i
It's a substring match. If it matches the entire string, it should be written/^[a-zA-Z0-9_-]@gmail\.com$/i
.
Square brackets in regular expressions refer to the"One character".
[a-z]
YesLowercase lettersInOne character
[A-Z]
YesUppercase lettersInOne character
[0-9]
YesNumberInOne character
[a-zA-Z0-9_-]
YesUppercase/lowercase letters, numbers, underscores, and hyphensInOne character
[a-z][A-Z][0-9]
YesThree charactersThe first is a lowercase letter, the second is a capital letter, and the third is a number.