"C #" regular Expressions match Chinese, English letters and numbers and _ Writing! and control the length of __ regular expressions
Source: Internet
Author: User
using System.Text.RegularExpressions;
Match Chinese: [\u4e00-\u9fa5]
English letter: [A-za-z]
Number: [0-9]
Match Chinese, English letters and numbers and _:
^[\u4e00-\u9fa5_a-za-z0-9]+$
At the same time determine the input length:
[\u4e00-\u9fa5_a-za-z0-9_] {4,10}
^[\w\u4e00-\u9fa5\uf900-\ufa2d]*$1, a regular expression containing only Chinese characters, numbers, letters, underscores cannot begin and end with an underscore:
^(?! _)(?!. *?_$) [a-za-z0-9_\u4e00-\u9fa5]+$ of which:
^ matches where the string begins
(?! _) cannot start with _
(?!. *?_$) cannot end with _
[a-za-z0-9_\u4e00-\u9fa5]+ at least one Chinese character, number, letter, underline
$ matches where the string ends
Put @ in front of the program, or you need to escape @ ^ (?! _)(?!. *?_$) [a-za-z0-9_\u4e00-\u9fa5]+$]
(or: @ "^" ^ (?!) _) \w* (?
2, only contain Chinese characters, numbers, letters, underline, the underline position is not limited:
^[a-za-z0-9_\u4e00-\u9fa5]+$
3. A string of numbers, 26 English letters, or underscores
^\w+$
4.2~4 a Chinese character
@ "^[\u4e00-\u9fa5]{2,4}$";
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.