JS Regular expression Matching digital letter underline and other _javascript skills

Source: Internet
Author: User
1, a regular expression, only contains Chinese characters, numbers, letters, underscores can not be underlined at the beginning and end: ^ (?!) _)(?!. *?_$) [a-za-z0-9_\u4e00-\u9fa5]+$ Where: ^ matches the place where the string begins (?! _) cannot begin with _ (?!. *?_$) can not end with _ [a-za-z0-9_\u4e00-\u9fa5]+ at least one Chinese character, number, letter, underscore $ and the end of the string match place in front of the program plus @, otherwise need \ \ to escape @ ^ (?! _)(?!. *?_$) [a-za-z0-9_\u4e00-\u9fa5]+$] [or: @] ^ (?! _) \w* (? <!_) $ "or @" ^[\u4e00-\u9fa50-9a-za-z_]+$ ") 2, only contains Chinese characters, numbers, letters, underscores, underline position is not limited to: ^[a-za-z0-9_\u4e00-\u9fa5]+$ 3, by the number 
 
Words, 26 English letters or underscores of the string ^\w+$ 4, 2~4 a kanji @ "^[\u4e00-\u9fa5]{2,4}$"; 5, ^[\w-]+ (\.[ \w-]+) *@[\w-]+ (\.[ \w-]+) +$: (ABC) + to analyze: XYZAbcAbcAbcXYZAbcAb xyzabcabcabcxyzabcab 6, [^\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)) {\ \ conform to rule} else 
 {\ \ exists an illegal character}
 

This is all in this article, and I hope it helps to learn about JavaScript regular expressions.

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.