This article will share with you the examples of using regular expressions to detect only Chinese characters, numbers, letters, and underscores. It is very simple and practical. We recommend this article for your reference.
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 *(?
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.