Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the Chinese regular expression like

Shulou Source: shulou.com Published: 2022-06-03 11:01:39 10月04日 Update

I would like to share with you what the Chinese regular expression is like. I believe most people don't know much about it, so share this article for your reference. I hope you will learn a lot after reading this article. Let's learn about it!

How about Chinese regular expressions

\ w matches only Chinese, numbers and letters. For Chinese people, only matching Chinese is often used, see below

Regular expressions that match Chinese characters: [\ u4e00 -\ u9fa5]

Maybe you also need to match double-byte characters. Chinese is also double-byte characters.

Match double-byte characters (including Chinese characters): [^\ X00 -\ xff]

Note: it can be used to calculate the length of a string (a double-byte character length meter 2recom ASCII character counter 1)

More common regular expression matching rules:

English letter: [a-zA-Z]

Number: [0-9]

Match Chinese, English letters and numbers and _:

/ / codefrom http://caibaojian.com/zhongwen-regexp.html

^ [\ u4e00 -\ u9fa5_a-zA-Z0-9] + $

Regular expressions of letters, numbers, underscores and Chinese characters

1. Regular expressions that have only letters, numbers, and underscores and cannot begin and end with an underscore: ^ (?! _) (?!. *? _ $) [a-zA-Z0-9] + $

Only letters and numbers: ^ [a-zA-Z0-9 _] + $

two。 At least one Chinese character, number, letter, underscore: "[a-zA-Z0-9 _\ u4e00 -\ u9fa5] +"

3. The regular expression of at least one Chinese character: "^ [\ u4e00 -\ u9fa5]"

4. Up to 10 Chinese characters: ValidationExpression= "^ [\ u4e00 -\ u9fa5] {0jue 10}"

5. It contains only Chinese characters, numbers, letters and underscores and cannot begin and end with an underscore: ^ (?! _) (?!. *? _ $) [a-zA-Z0-9 _\ u4e00 -\ u9fa5] + $

Explanation:

^ matches the beginning of the string

(? _) cannot start with _

(?. *? _ $) cannot end with _

[a-zA-Z0-9 _\ u4e00 -\ u9fa5] + at least one Chinese character, number, letter, underscore

$matches the end of the string

6. A regular expression that contains only Chinese characters, numbers, letters, underscores, not the beginning and end of an underscore:

^ (! _) (?!. *? _ $) [a-zA-Z0-9 _\ u4e00 -\ u9fa5] + $

The above is all the content of the article "what is the Chinese regular expression?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Letter number regular expression Chinese character Chinese character underscore byte beginning string article content only place more length English not much Chinese Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia MySQL Shulou Tech Info Shulou Information Shulou Technology