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