Read about unix regular expression examples, The latest news, videos, and discussion topics about unix regular expression examples from alibabacloud.com
charactersVerify QQ numberVerify e-mail (verify MSN number)Verify the identity card number (rough check, the best server-side tuning class library again fine verification)Verify mobile phone number (including 159, does not contain PHS)Verify phone number (very complex, vs.net2005 is wrong)Verify PassportVerify IP, verify domain authentication credit card (support Visa Card, MasterCard, Discover, American Express card)Verify ISBN International Standard ISBNVerify GUID Global Unique identifierVer
made.
Similarly,
Note that the Regular Expression Engine is case sensitive by default.
· Special characters
11 characters are reserved for special purposes. They are:
[] \ ^ $. |? * + ()
These special characters are also called metacharacters.
If you want to use these characters in a regular expressionCompositionThis character, you need to use th
.
\ S
Matches a non-blank character, equal to/[^ \ n \ f \ r \ t \ v]/
\ T
Match a tab
\ V
Match a Duplicate Tab
\ W
Match a character that can make up a word (alphanumeric, this is my free translation, containing numbers), including underscores, such as [\ W] matching 5 in "$5.98", equal to [a-zA-Z0-9]
\ W
Match a character that cann
and exclude the characters/symbols which need to be validated.Eg: "^ \ W [^ ] * $" is the solution to take all alpha numeric and special symbols into T " #8221 ;.
Other examples: A) There shoshould not be "1" as first digit ,?^ [^ 1] \ D * $? This will exclude 1 as first digit.
B) There shoshould not be "1" at any place?^ \ D [^ 1] * $? This will exclude the 1 at any place in the sequence.
Note:Here ^ operator is used not only to start the strin
PS: In all examples, regular expression matching results are included between [and] in the source text. In some examples, java is used. If the regular expression is used in java, it will be described in the corresponding area. All
them with a backslash "\" (Escape). For example you want to match "1+1=2", the correct expression is It is important to note that,In programming languages, it is important to note that some special characters are processed by the compiler before being passed to the regular engine. So the regular expression
N
This article mainly introduces the regular expression of common examples of collation, very good, with reference value, the need for friends can refer to the next
Collect regular expression instances that are used frequently in business to facilitate later searches and red
string may have more than one substring to match a given regular expression. When replacing a string with a Patternmatcherinput object as a parameter, the syntax for the above three methods is as follows:· Boolean matches (Patternmatcherinput input, pattern pattern)· Boolean Matchesprefix (Patternmatcherinput input, pattern pattern)· Boolean contains (Patternmatcherinput input, pattern pattern)Third, appli
. Here are some simple examples to discuss the use of the RE module and familiarize yourself with the basic regular syntax that has been discussed above. Later, the advanced operations of some regular expressions are discussed.Like the ideas discussed earlier, the RE module matches strings in roughly 3 steps:
Use Re.compile to get a compiled pattern obje
previous matched position.Similarly, Note that the Regular Expression Engine is case sensitive by default. · Special characters11 characters are reserved for special purposes. They are:[]/^ $. |? * + ()These special characters are also called metacharacters.If you want to use these characters as text characters in a regular
charactersVerify QQ numberVerify e-mail (verify MSN number)Verify the identity card number (rough check, the best server-side tuning class library again fine verification)Verify mobile phone number (including 159, does not contain PHS)Verify phone number (very complex, vs.net2005 is wrong)Verify PassportVerify IP, verify domain authentication credit card (support Visa Card, MasterCard, Discover, American Express card)Verify ISBN International Standard ISBNVerify GUID Global Unique identifierVer
From a string perspective, Chinese is not as neat and standard as English, which is an unavoidable reality. This article combines the online data and personal experience, take Python language as an example, a little summary. Welcome to add or pick the wrong. A little experience you can use the repr () function to view the original format of a string. This is useful for writing regular expressions. The Python re module has two similar functions: Re.
Microsoft | grammar | regular REGULAR expression syntax
A regular expression is a literal pattern consisting of ordinary characters (such as characters A through Z) and special characters (called metacharacters). This pattern describes one or more strings to be matched when
A summary of the g,m parameters of regular expressionsIn order to answer the meaning of "/g" in "Regular expression (/[^0-9]/g,"). "The question, and in order to be able to have a more comprehensive and profound understanding of regular expressions, I will summarize some of the key points and confusing places."
Summa
editor also supports other features, including the search-replace tool, which makes it quite easy to edit a text file.
Regular expressions are similar, but better. Regular expressions can be considered as an extremely advanced search-replacement tool, which frees us from the pain: you do not have to write custom data validation examples to check the email addres
verification)Verify mobile phone number (including 159, does not contain PHS)Verify phone number (very complex, vs.net2005 is wrong)Verify PassportVerify IP, verify domain authentication credit card (support Visa Card, MasterCard, Discover, American Express card)Verify ISBN International Standard ISBNVerify GUID Global Unique identifierVerifying file paths and extensionsValidating HTML color values
... ...I knowI've always had a pair of invisible wings.Take me to flyGive me hope.I finallySeeAll
Three things ordinary people do not understand: The doctor's prescription, Taoist Ghost, programmer get regular expression What is a regular expression?
Regular expressions, also known as regular expressions, are called
class library again fine verification)
Verify mobile phone number (including 159, does not contain PHS)Verify phone number (very complex, vs.net2005 is wrong)
Verify Passport
Verify IP, verify domain authentication credit card (support Visa Card, MasterCard, Discover, American Express card)Verify ISBN International Standard ISBN
Verify GUID Global Unique identifierVerifying file paths and extensionsValidating HTML color values
... ...I knowI've always had a pair of invisible wings.Take me
About Reverse References
Copy Code code as follows:
Test function
function Matchreg (Reg, str) {
var result = Str.match (reg);
if (result) {
Console.dir (result);
} else {
Console.log (' match failed ');
}
}
var reg =/([a-za-z]{0,6}) \1/;
var str = ' andrewandrew ';
Test passed
Matchreg (Reg, str);
Do not record subexpression matches by (?:p Attern) (in this case, Andrew)
So \1 the subexpression that matched the content failed.
Note: The emph
is common to locate strings that match complex patterns when writing a program or Web page that handles text. Regular expressions are used to describe such patterns. Thus, a regular expression is a reduced code for a pattern. For example, the pattern "\w+" is an accurate way of expressing "matching any non-empty string that contains alphanumeric characters." NET
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.