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.
based on the compiled regular expression, and multiple matcher can share a pattern object.
Now let's look at a simple example and then analyze it to see how to generate a pattern object and compile a regular expression, and then split the target string according to the
Regular expression syntax examples: ^ [t] * $ ^ [t] * $ matches a blank line. D {2}-d {5} d {2}-d {5} verify that an ID number consists of a 2-character, a hyphen, and a 5-digit number. (. *). * 1 (. *). * 1 matches an HTML tag. The following table lists metacharacters and regular expressions.
Regular
object will useMatcher ()Method to generate a Matcher instance. Then, the Matcher instance can be used to match the target String Based on the compiled regular expression. Multiple Matcher instances can share a Pattern object.
Now let's take a look at a simple example and analyze it to learn how to generate a Pattern object and compile a
Python Regular Expression replacement string function re. sub usage example, pythonre. sub
This example describes how to use the Python Regular Expression replacement string function re. sub. We will share this with you for your
In the programming of the basic will use regular expression to deal with the data, then the following specific in PHP how to use it, this article through concrete examples, to explain the use of the PHP expression in the method.
Recently, using PHP to write an application, mainly the processing of regular expressions,
example, Java regular expressions are used to extract all the Population Series values in the following text.
The population of China is 1295000000
The population of Japan is 135000000
Case 3:
Group)The Logic block in the string is converted and adjusted before and after the position. It is designed to be a regul
Regular Expression example
Expression
Match
/^/S * $/
Matches empty rows.
// D {2}-/d {5 }/
The ID number consists of two digits, one hyphen and five digits.
/
Matches HTML tags.
The following table contains a complete list of metacharacters and their behavior in
This article mainly introduces the implementation of the regular expression grouping capture operation in PHP, and analyzes the relevant implementation methods of the PHP regular expression acquisition and the use of the packet capture operation with the example form, and th
Some examples
Regular Expression
Description
/\ B ([a-z] +) \ 1 \ B/gi
Position where a word appears consecutively
/(\ W +): \/([^/:] +) (: \ d *)? ([^ #] *)/
Parses a URL into a protocol, domain, port, and relative path.
/^ (? : Chapter | Section) [1-9] [0-9] {0, 1} $/
Locate the Unit
/[-A-z]/
A to z contains 26 letters plus A-number.
/Te
Php Regular Expression modifier usage example details, php instance details
This example describes the php Regular Expression modifier usage. We will share this with you for your reference. The details are as follows:
Modifier:
P
Explain the example code of PHP regular expression multi-line matching. In the course of study, many problems need to be solved continuously in practice. When matching PHP regular expressions, we only use regular expression functi
Because the regular expression is a very complex system, this example only to give some ideas for getting started, more please refer to the relevant books and self-exploration.\ \ counter Slash\ t interval (' \u0009 ')\ n line break (' \u000a ')\ r Enter (' \u000d ')\d number equivalent to [0-9]\d non-numeric equivalent to [^0-9]\s blank symbol [\t\n\x0b\f\r]\s n
Example of the replace method of a JavaScript string object (for string replacement or regular expression replacement), javascriptreplace
JavaScript replace Method
The replace method is used to replace some strings with other strings, or replace strings that match the regular expre
Php regular expression to delete the img Tag original method example, imgfont
This example describes how to delete the img Tag using php regular expressions. We will share this with you for your reference. The details are as follows:
I. Problems
The img label in the body
This article mainly introduces the Python regular expression simple example, and analyzes the problems encountered in the Python simple string regular expression matching test and related precautions, for more information about Python re
Regular expressions are a special sequence of characters that can help match or find other strings or string sets, using patterns that maintain a specialized syntax.
The regular expression literal is a pattern between a slash or any delimiter%r as follows:Grammar:
Copy Code code as follows:
/pattern/
/PATTERN/IM # option can be specified
%r!/
Introduction
The regular expression describes a string matching mode. It can be used to: (1) check whether a string contains a child string that complies with a specific rule and obtain the child string; (2) flexibly replace strings according to matching rules.
Regular Expressions are actually very simple to learn. A few abstract concepts are also easy to underst
]); SYSTEM.OUT.PRINTLN ("The modified legal address should resemble:" +input);}}} For example, we type in the command line: Java email [email protected]Then the output will be: Email address cannot be ' www. ' StartingIf the email you entered is @[email protected]The output is: Email address cannot be '. ' or ' @ ' as the starting characterWhen input is: cgjmail#$%@163.netThen the output is:The email addres
Php regular expression learning instances. ^ The: match a string starting with The; ofdespair $: match a string ending with ofdespair; ^ abc $: match a string starting with abc and ending with abc, actually, only abc matches "^ The": matches The string starting with ";
"Of despair $": match the string ending with "of despair;
"^ Abc $": matches strings starting with abc and ending with abc. In fact, only
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.