([A-zA-Z0-9 _-]) represents what?

Source: Internet
Author: User
Tags email string
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/iMatching2abcDEF123@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.comPart

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".

  1. [a-z]YesLowercase lettersInOne character
  2. [A-Z]YesUppercase lettersInOne character
  3. [0-9]YesNumberInOne character
  4. [a-zA-Z0-9_-]YesUppercase/lowercase letters, numbers, underscores, and hyphensInOne character
  5. [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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.