Js regular expressions match numbers, letters, underscores, and so on. js Regular Expressions
1. A regular expression that only contains Chinese characters, numbers, letters, and underscores. It cannot start or end with a hyphen: ^ (?! _)(?!. *? _ $) [A-zA-Z0-9 _ \ u4e00-\ u9fa5] + $ where: ^ matches the place where the string starts (?! _) Cannot start (?!. *? _ $) Cannot end with _ [a-zA-Z0-9 _ \ u4e00-\ u9fa5] + at least one Chinese character, number, letter, underline $ match with the end of the string in front of the program add @, otherwise, escape @ "^ (?! _)(?!. *? _ $) [A-zA-Z0-9 _ \ u4e00-\ u9fa5] + $ "(or: @" ^ (?! _) \ W *(? <! _) $ "Or @" ^ [\ u4E00-\ u9FA50-9a-zA-Z _] + $ ") 2, only contains Chinese characters, numbers, letters, underscores, unlimited underline 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-] +) + $ use (Abc) + for analysis: XYZAbcAbcAbcXYZAbcAb large, [^ \ u4E00-\ u9FA50-9a-zA-Z _] 34555 # 5' --> 34555 # 5' [\ u4E00-\ u9FA50-9a-zA-Z _] eiieng_89 _ ---> eiieng_89 __'; 'eiieng _ 88 & * 9 _ --> _ '; 'eiieng _ 88 & * 9 _'; 'eiieng _ 88 _ & * 9 _ --> _'; 'eiieng _ 88 _ & * 9 _ public bool RegexName (string str) {bool flag = Regex. isMatch (str, @ "^ [a-zA-Z0-9 _ \ u4e00-\ u9fa5] + $"); return flag ;} regex reg = new Regex ("^ [a-zA-Z_0-9] + $"); if (reg. isMatch (s) {\ compliant rule} else {\ contains invalid characters}
The above is all the content of this article. I hope it will be helpful for you to learn javascript regular expressions.