Javascript Regular Expressions match numbers, letters, underscores, etc. _ javascript tips-js tutorial

Source: Internet
Author: User
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.

Related Article

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.