:^(\d{3})-(\d{3,8})$Two groups are defined separately, and the area code and local numbers can be extracted directly from the matching string: >>> m = Re.match (r ' ^ ( \D{3})-(\d{3,8}) $ ', ' 010-12345 ') >>> m0, 9), Match= ' 010-12345 ' > >>> m.group (0) ' 010-12345 ' >>> m.group (1) ' 010 ' Span class= "Hljs-prompt" >>>> m.group (2) ' 12345 ' >>> m.groups () ( ' 010 ', ' 12345 ') Through the experiment, if you do not use parentheses, the resulting Match object class can be used such as
composed of letters, numbers, or underscores, email and phone numbers all have their own rules. Therefore, regular expressions can be used to verify these fields.
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.
tokens ).
#include
Http://topic.csdn.net/t/20040818/10/3285376.htmlASP. NET fully supports regular expression processing. Regular Expressions provide an advanced but not intuitive method for string matching and processing. If you have used regular expressionsAs you all know, reg
, {2} means that \d is to be matched 2 times. Months(\d{2})----\d represents a number, {2} means that \d is to be matched 2 times. Day(\d{3})----\d represents a number, {3} means that \d is to be matched 3 times. Id([0-9]| X) $----$ representation ([0-9]| X) matches at the end, without qualifiers so ([0-9]| X) can and can match only one character, which is either 0 to 9 or the letter "X". (check code)Four, regular on-line generation and testing toolsW
can set the $options to $i.The following command looks for a case-insensitive string, w3cschool.cc:>db. Posts. Find({post_text: {$regex:"w3cschool.cc",$options:"$i"}}) All data containing the string w3cschool.cc are returned in the collection and are not case-sensitive:{ "_id":ObjectId("53493d37d852429c10000004"),"Post_text":"hey! This was my post on w3cschool.cc "," tags ":[" Tutorialspoint "]}
Array elements use regular expressionsWe c
Quick recall Regular Expression
This is not an entry-level article, but if you have an understanding of regular expressions or have used them, it can help you quickly recall them. Reading this article requires you to have used regular expressions or some knowledge before, because I have not written many examples. To su
row.The row at the end of the search is.Woody @ xiaoc :~ /Tmp $ grep-n' \ .w.'regular_express.txt//. It is a special symbol of a regular expression, so use \ escape1: "Open Source" is a good mechanic to develop programs.2: apple is my favorite food.3: Football game is not use feet only.4: this dress doesn' t fit me.5: However, this dress is about $3183 dollars.6: GNU
Escape Character '\' to escape, that is '\.'
Metacharacters-multiple-choice Structure
The multiple-choice structure is similar to the character group, which means "or". You can select one of them. But the biggest difference between them is that The 'character group' can only be selected between a single character. The multiple-choice structure is selected between multiple expressions. For example:
Regular Express
The translation I translated from gun manual is a little poor, but I can understand it easily. In fact, laruence's Private food contains part of the content of 90% in GNU manual, for more information, see laruence Linux cainiao.
Match dictionary lettersThe dot (.) matches any character other than line breaks and null, for example, 'a. B 'matches a string of three characters starting with a and ending with B.After B is followed by a, the result is a
The example in this article describes a method that matches a set of characters in a regular expression tutorial. Share to everyone for your reference, as follows:
Note: In all examples, the expression match results are included in the source text between "and", some examples will be implemented in Java, if the Java i
expressionsIf the retrieval needs to be case insensitive, we can set the $options to $i. The following command looks for a case-insensitive string, w3cschool.cn: >db.posts.find ({post_text:{$regex: "w3cschool.cn", $options: "$i"}})
All data containing the string w3cschool.cn are returned in the collection and are not case-sensitive: {
"_id": ObjectId ("53493d37d852429c10000004"),
"Post_text": "hey! This was my post on w3cschool.cc ",
" tags ": [" Tutorialspoint "]
}
Array elements
A gentleman is open-minded and optimistic; A small person is narrow-minded and pessimistic."The gentleman is magnanimous, the villain long Obsession"Reference: Bird Brother's Linux private cuisine Basic Study (third edition)The basis of regular expression1. What is a regular expression The regular
= ' Tom Jer Ry Hello Bye House good God's
print Re.match (pattern, string). Group ()
1-3 matches any word and single letter separated by a single comma and a single white delimiter, such as the first character of a last name
# 1-3
# Output results S.n.owfall and S.N. Owfall pattern
= R ' ([A-z]\.) + ? [A-z] [a-z]+ '
string1 = ' S.n.owfall '
string2 = ' s.n. Owfall '
print re.match (pattern, string1). Group ()
Print Re.match (pattern, string2). Group ()
1-4 matching the collection of all vali
Example of C ++ TR1 Regular Expression LibraryAuthor: que rongwenTime: 2011/8/13
[Background]To use regular expressions in a program, you must first have database support. currently, the main influential C ++ regular Library is the GNU Regex Library, which is part of glibc.
Next we will provide a PHP regular expression to match the specified tag in the string to implement the program code. if you need to learn, please refer to this tutorial. In PHP applications, regular expressions are mainly used for: bull; regular
The method of using PCRE regular-Expression Vulnerability CVE-2015-0318 in Flash0x00 Preface
Issue 199/PSIRT-3161/CVE-2015-0318
Brief Introduction: The PCRE Regular Expression parsing engine used by Flash
Note: Obviously, this engine has a vulnerability. You can see the vulnerability information on the above issue page
I 've been writing this for the last 20 days... it's finally finished (the road to endless reconstruction ...)... I would like to thank the author of VC and re2 for their blog guidance and the source code reference of VC. thank you very much! Great inspiration. The scheme of traversing part of the regular syntax tree of VC aggregation is really subtle! Previously, although I knew how to traverse heterogeneous trees in the visitor mode, I did not know
m8pp
()
Put all the elements of the candidate in () and separate them with |
Examples of "a (1 | 2 | 3) bc" satisfying a1bc and mba3bcd
Note: {} needs to be transferred in Zheng's expression, but {} () does not.
Note:
4. Standard character classes
Character class
Meaning
[: Alnum:]
Letters and numbers, equivalent to [A-Za-z0-9]
[: Word:]
[: Alnum _
[: Alpa:]
Letter, equivalent to [A
Linux regular expression-POSIX character class
POSIX standardizes the meanings of Regular Expression characters and operators. This standard defines two types of Regular Expressions: Basic Regular Expressions (BRE), grep and sed u
matches}There are other methods of matcher that have not been sorted out,There are other methods of the Matcher class that are not organized:1.group (int Group) method2.appendReplacement ()/Appendtail ()/ReplaceAll ()/Replacefirst ()/quotereplacement ()The Find () method of the 99.Matcher class, the Start () method, and the end () method More detailed regular expression posts can be found in:Official Micr
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.