Regular Expression-user name rules only contain Chinese characters, numbers, letters, and underscores

Source: Internet
Author: User

First, we recommend a website for online testing/learning regular expressions,

Http://www.gskinner.com/RegExr/

1. A regular expression that only contains Chinese characters, numbers, letters, and underscores. It cannot start or end with or after the following line:

^ (?! _)(?!. *? _ $) [A-zA-Z0-9 _ \ u4e00-\ u9fa5] + $ where:
^ Match the start point of the string
(?! _) Cannot start _
(?!. *? _ $) Cannot end _
[A-zA-Z0-9 _ \ u4e00-\ u9fa5] + at least one Chinese character, number, letter, underline
$ Match the end of the string

Put inProgramAdd @ in front of, otherwise escape @ "^ (?! _)(?!. *? _ $) [A-zA-Z0-9 _ \ u4e00-\ u9fa5] + $"
(Or: @ "^ (?! _) \ W *(? <! _) $ "Or @" ^ [\ u4e00-\ u9FA50-9a-zA-Z _] + $ ")

2. It only contains Chinese characters, numbers, letters, and underscores. The underline is not limited to any position:
^ [A-zA-Z0-9 _ \ u4e00-\ u9fa5] + $

3. A string consisting of digits, 26 English letters, or underscores
^ \ W + $

4, 2 ~ 4 Chinese Characters
@ "^ [\ U4e00-\ u9fa5] {2, 4} $ ";

5,
^ [\ W-] + (\. [\ W-] +) * @ [\ W-] + (\. [\ W-] +) + $

Analysis with :( ABC) +: xyzabcabcabcxyzabcab

 
XYZAbcabcabcXYZABCAB

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.