Js Regular Expression (Common username, password ,,,,)

Source: Internet
Author: User
Tags control characters uppercase letter

// Check whether it is composed of digits
[Code] function isDigit (s) {var patrn =/^ [0-9] {1, 20} $/; if
(! Patrn.exe c (s) return false return true} [/code]

// Check Logon Name: You can enter only 5-20 strings starting with a letter, which can contain numbers, "_", and ".".
[Code] function
IsRegisterUserName (s) {var patrn =/^ [a-zA-Z] {1} ([a-zA-Z0-9] | [. _]) {} $/; if
(! Patrn.exe c (s) return false return true} [/code]

// Check user name: only 1-30 strings starting with letters can be entered
[Code] function isTrueName (s) {var
Patrn =/^ [a-zA-Z] {1, 30} $/; if (! Patrn.exe c (s) return false return true }}}
// Verification password: only 6-20 letters, numbers, and underscores can be entered. [code] function isPasswd (s) {var
Patrn =/^ (\ w) {6, 20} $/; if (! Patrn.exe c (s) return false return true} [/code]

// Verify the phone number and fax number. The phone number can start with "+" and contain "-" in addition to numbers.
[Code] function isTel (s) {// var
Patrn =/^ [+] {0, 1} (\ d) {1, 3} []? ([-]? (\ D) {}) + $/; var patrn =/^ [+] {} (\ d) {1, 3 }[
]? ([-]? (\ D) | []) {1, 12}) + $/; if (! Patrn.exe c (s) return false return true}
[/Code]

// Verify the mobile phone number. It must start with a number and can contain "-" in addition to a number.
[Code] function isMobil (s ){
Var patrn =/^ [+] {0, 1} (\ d) {1, 3} []? ([-]? (\ D) | []) {1, 12}) + $/; if (! Patrn.exe c (s ))
Return false return true} [/code]

// Verify the zip code
[Code] function
IsPostalCode (s) {// var patrn =/^ [a-zA-Z0-9] {3,12} $/; var patrn =/^ [a-zA-Z0-9
] {3, 12} $/; if (! Patrn.exe c (s) return false return true} [/code]

// Verify the search keyword
[Code] function isSearch (s) {var
Patrn =/^ [^ '~! @ # $ % ^ & * () + = |\\] [\] \{\}:;' \,. <>/?] {1} [^ '~! @ $ % ^ & () + = |\\]
[\] \{\}:; '\,. <>?] {0, 19} $/; if (! Patrn.exe c (s) return false return true}
Function isIP (s) // by zergling {var patrn =/^ [0-9.] {1, 20} $/; if (! Patrn.exe c (s ))
Return false return true} [/code]

Regular Expression
[Code] "^ \ d + $" // non-negative integer (positive integer + 0)
"^ [0-9] * [1-9] [0-9] * $" // positive integer "^ (-\ d +) | (0 + )) $ "// non-positive integer (negative integer + 0)
"^-[0-9] * [1-9] [0-9] * $" // negative integer "^ -? \ D + $ "// integer
"^ \ D + (\. \ d + )? $ "// Non-negative floating point number (Positive floating point number + 0)
"^ ([0-9] + \\. [0-9] * [1-9] [0-9] *) | ([0-9] * [1-9] [0-9] * \. [0-9] +) | ([0-9] * [1-9] [0-9] *) $"
// Positive floating point number "^ (-\ d + (\. \ d + )?) | (0 + (\. 0 + )?)) $ "// Non-Positive floating point number (negative floating point number + 0)
"^ (-([0-9] + \\. [0-9] * [1-9] [0-9] *) | ([0-9] * [1-9] [0-9] * \. [0-9] +) | ([0-9] * [1-9] [0-9] *) $"
// Negative floating point number "^ (-? \ D +) (\. \ d + )? $ "// Floating point number" ^ [A-Za-z] + $ "// A string consisting of 26 letters
"^ [A-Z] + $" // a string consisting of 26 uppercase letters "^ [a-z] + $" // consisting of 26 lowercase letters string
"^ [A-Za-z0-9] + $" // a string consisting of digits and 26 letters "^ \ w + $" // a number, 26 letters, or underscores string
"^ [\ W-] + (\\. [\ w-] +) * @ [\ w-] + (\\. [\ w-] +) + $ "// email address
"^ [A-zA-z] +: // (\ w + (-\ w + )*)(\\. (\ w + (-\ w + )*))*(\\? \ S *)? $ "// Url
"^ [A-Za-z0-9 _] * $" [/code]

Detailed explanation of Regular Expressions

Introduction

In short, regular expressions are a powerful tool for pattern matching and replacement. Its functions are as follows:

Test a mode of a string. For example, you can test an input string to see if there is a phone number or a credit card number. This is called Data Validity verification.

Replace text. You can use a regular expression in a document to identify a specific text, and then delete it all or replace it with another text.

Extract a substring from the string based on the pattern match. It can be used to search for specific text in text or input fields.

Basic syntax

After a preliminary understanding of the functions and functions of a regular expression, let's take a look at the syntax format of the regular expression.

The regular expression format is generally as follows:

/Love/the part between the "/" delimiters is the pattern to be matched in the target object. You only need to place the pattern content of the desired matching object between the "/" delimiters. To enable users to customize the mode content more flexibly, regular expressions provide special "metacharacters ". Metacharacters are special characters that have special meanings in regular expressions. They can be used to specify the mode in which the leading character (that is, the character located before the metacharacters) appears in the target object.

Frequently Used metacharacters include "+", "*", and "?".

The "+" metacharacter specifies that its leading character must appear one or more times consecutively in the target object.

The "*" metacharacter specifies that the leading character must appear zero or multiple times in the target object.

"?" Metacharacter specifies that the leading object must appear zero or once consecutively in the target object.

Next, let's take a look at the specific application of the regular expression metacharacters.

/Fo +/because the regular expression above contains the "+" metacharacter, it indicates that it can be used with
"Fool", "fo", or "football" appear after the letter f, and match one or more character strings of the letter o.

/Eg */because the above regular expression contains "*" metacharacters, it can be used with "easy", "ego", or
"Egg" and so on.

/Wil? /Because the above regular expression contains "?" Metacharacters, which can be used
"Win", or "Wilson", and so on, after the letter I, zero or one character string matches.

Sometimes I don't know how many characters to match. To adapt to this uncertainty, regular expressions support the concept of delimiters. These qualifiers can specify how many times a given component of a regular expression must appear to match.

{N} n is a non-negative integer. Match n times. For example, 'O {2} 'cannot match 'O' in "Bob", but can match two o in "food.

{N,} n is a non-negative integer. Match at least n times. For example, 'O {2,} 'cannot match 'O' in "Bob", but can match all
O. 'O {1,} 'is equivalent to 'o + '. 'O {0,} 'is equivalent to 'o *'.

Both {n, m} m and n are non-negative integers, where n <=
M. Match at least n times and at most m times. For example, "o {1, 3}" matches the first three o in "fooooood. 'O {0, 1} 'is equivalent
'O? '. Note that there must be no space between a comma and two numbers.

In addition to metacharacters, you can also precisely specify the frequency of occurrence of a pattern in a matching object. For example,/jim {2, 6 }/
The above regular expression specifies that the character m can appear 2-6 times consecutively in the matching object. Therefore, the above regular expression can match strings such as jimmy or jimmm.pdf.

After a preliminary understanding of how to use regular expressions, let's take a look at the usage of several other important metacharacters.
[Code]
\ S: Used to match a single space character, including the tab key and line break; \ S: Used to match all characters except a single space character; \ d: Used to match numbers from 0 to 9;
\ W: Used to match letters, numbers, or underscores; \ W: Used to match all characters that do not match \ w;.: Used to match all characters except line breaks. [/Code]

(Note: \ s and \ S and \ w and \ W can be regarded as inverse operations)
Next, let's take a look at how to use the above metacharacters in regular expressions through examples.
/\ S +/
The above regular expression can be used to match one or more space characters in the target object.

/\ D000/if we have a complex financial statement in hand, we can easily find all the total amount of RMB through the above regular expression.

In addition to the metacharacters described above, regular expressions also have a unique special character, that is, the positioning character. Specifies the position where the matching mode appears in the target object.
Commonly used positioning characters include "^", "$", "\ B", and "\ B ".
[Code] The "^" operator specifies that the matching mode must start with the target string.
The "$" operator specifies that the matching mode must appear at the end of the target object. The "\ B" operator specifies that the matching mode must appear at either the beginning or end of the target string.
The "\ B" Locator specifies that the matching object must be within the boundary of the start and end of the target string. That is, the matching object cannot start with the target string, it cannot end with the target string. [/Code]

Similarly, we can regard "^" and "$" as well as "\ B" and "\ B" as two sets of operators for inverse operation. For example:
/^ Hell/because the regular expression above contains the "^" operator, it can match a string starting with "hell", "hello", or "hellhound" in the target object.
/Ar $/because the regular expression above contains the "$" operator, it can match the string ending with "car", "bar", or "ar" in the target object.
/\ Bbom/because the above regular expression pattern starts with the "\ B" locator, you can use the "bomb" or
Strings starting with "bom" are matched. /Man \ B/because the above regular expression pattern ends with the "\ B" positioning character, you can use "human", "woman" or
The string ending with "man" matches.
To make it easier for users to set matching modes flexibly, regular expressions allow users to specify a range in the matching mode, not limited to specific characters. For example:

[Code]/[A-Z]/the above regular expression will match any uppercase letter from A to Z.
/[A-z]/the above regular expression will match any lowercase letter in the range from a to z. /[0-9]/the above regular expression will match any number from 0 to 9.
/([A-z] [A-Z] [0-9]) +/the above regular expression will be associated with any string consisting of letters and numbers, for example, "aB0" matches. [/Code]

Note that you can use "()" in the regular expression.
Combines strings. The content contained by the "()" symbol must appear in the target object at the same time. Therefore, the above regular expression cannot be
Strings such as "abc" are matched because the last character in "abc" is a letter rather than a number.

If we want to implement the "or" operation similar to the programming logic in a regular expression and select one of multiple different modes for matching, we can use the pipeline operator
"| ". For example:/to | too | 2/the above regular expression will match "to", "too", or "2" in the target object.

There is also a common operator in the regular expression, that is, the negative character "[^]". Different from the positioning character "^" described above
"[^]" Specifies that the target object cannot contain strings specified in the mode. For example:/[^ A-C]/the above string will match any character except A, B, and C in the target object. Generally, when "^" appears in
In "[]", it is regarded as a negative operator. When "^" is outside "[]" or "[]" is not found, it should be regarded as a positioning character.

Finally, you can use the Escape Character "\" to add metacharacters to the regular expression mode and find matching objects. Example:/Th \*/
The above regular expression will match "Th *" in The target object rather than ".

After constructing a regular expression, you can evaluate the value like a mathematical expression, that is, you can evaluate the value from left to right in a priority order. The priority is as follows:
[Code] 1. \ Escape Character
2 .(),(? :),(? =), [] Parentheses and square brackets 3. *, + ,?, {N}, {n ,}, {n, m} qualifier 4. ^, $,
\ Anymetacharacter location and sequence 5. | "or" operation [/code]

Use instance
In JavaScript
1.2 contains a powerful RegExp () object that can be used to match regular expressions. The test () method can check whether the target object contains the matching mode and return true or false accordingly.

We can use JavaScript to write the following script to verify the validity of the email address entered by the user.
[Code] <Script language = "Javascript1.2"> <! -- Start hiding
Function verifyAddress (obj) {var email = obj. email. value; var
Pattern =/^ ([a-zA-Z0-9 _-]) + @ ([a-zA-Z0-9 _-]) + (\. [a-zA-Z0-9 _-]) +/; flag =
Pattern. test (email); if (flag) {alert ("Your email address is
Correct !"); Return true;} else {
Alert ("Please try again !"); Return false ;}}
// Stop hiding --> </script> <Form onSubmit = "return verifyAddress (this);"> <input name = "email"
Type = "text"> <input type = "submit"> </form>
</Body>

Regular Expression object
This object contains the regular expression mode and a flag indicating how to apply the mode.
[Code]
Syntax 1 re =/pattern/[flags] syntax 2 re = new RegExp ("pattern", ["flags"]) [/code]

Parameters
Re
Required. Name of the variable to be assigned a value in the regular expression mode.

Pattern

Required. The regular expression mode to use. If Syntax 1 is used, use the "/" character separation mode. If syntax 2 is used, quotation marks are used to mark the format.

Flags

Optional. If syntax 2 is used, the flag is enclosed in quotation marks. The flag can be used in combination and available include:
[Code] g (full-text search for all occurrences of pattern)
I (case-insensitive) m (multi-row search) [/code]

Example

The following example creates an object (re) that contains the Regular Expression Pattern and related signs to demonstrate the usage of the regular expression object. In this example, the regular expression object used as the result is also used for match
Method:
[Code] function MatchDemo () {var r, re; // declare the variable. Var s = "The rain in
Spain falls mainly in the plain "; re = new RegExp (" ain "," g "); // create a regular expression object. R =
S. match (re); // search for matching in string s. Return (r);} [/code]

Return Value:
Ain, ain \\
Attribute lastIndex attribute | source attribute \\
Method compile method | exec Method
| Test Method \\
Required version 3 \\
See RegExp object | regular expression syntax | String object \\

Exec Method

Run the search in the string in regular expression mode and return an array containing the search result.
RgExp.exe c (str)

Parameters

RgExp
Required. A regular expression object that contains the regular expression mode and available flag.

Str
Required. The
String object or String text.

Description \\
If the exec method does not find a match, it returns null. If it finds a match, exec
Returns an array and updates the global RegExp.
To reflect the matching results. The 0 element of the array contains the complete match, and the 1st to nelement contains any child match in the match. This is equivalent to a match without a global flag.
Method.
If a global flag is set for the regular expression, exec searches for it at the position indicated by the value of lastIndex. If the global flag is not set, exec ignores
The value of lastIndex, which starts from the start position of the string.

The array returned by the exec method has three attributes: input, index, and
LastIndex. The Input attribute contains the entire searched string. The Index attribute contains the position of the matched substring in the searched string. LastIndex
The attribute contains the next position of the last character in the match.

Example \\
The following example illustrates the usage of the exec method:
[Code]
Function RegExpTest () {var ver = Number (ScriptEngineMajorVersion () + "." +
ScriptEngineMinorVersion () if (ver >=5.5) {// test the JScript version. Var src =
"The rain in Spain falls mainly in the plain."; var re = // \ w +/g; // create The regular expression mode.
Var arr; while (arr = re.exe c (src ))! = Null) document. write (arr. index + "-" +
Arr. lastIndex + arr + "\ t");} else {alert ("Please use the updated version of JScript");} [/code]

Returned value: 0-3The 4-8rain 9-11in 12-17Spain 18-23falls 24-30mainly 31-33in
34-37the 38-43plain

Test Method \\
Returns a Boolean value indicating whether the pattern exists in the searched string.

Rgexp. test (str)

Parameter \\
Rgexp
Required. A regular expression object that contains the regular expression mode or available flag.

Str
Required. The string to be searched.

Description
The test method checks whether a mode exists in the string. If yes, the system returns
True. Otherwise, false is returned.
The attributes of the global RegExp object cannot be modified by the test method.

Example
The example below illustrates
Usage of the test method:
[Code] function TestDemo (re, s) {var s1; // declare the variable. //
Check whether a regular expression exists in the string. If (re. test (s) // test whether the object exists. S1 = "contains"; // s inclusion mode. Else s1
= "Does not contain"; // s does not contain the mode. Return ("'" + s + "'" + s1 + "'" + re. source +
"'"); // Returns a string. } [/Code]

Function call: document. write (TestDemo (/ain +/,"
Rain in Spain falls mainly in the plain ."));

Returned value: 'The rain in Spain
Falls mainly in the plain. 'containin' ain +'

Match Method
Use the regular expression mode to perform a query on the string and return the result containing the query as an array. \\

StringObj. match (rgExp)

Parameter \\
StringObj
Required. String to be searched
Object or string text.

RgExp

Required. It is a regular expression object that contains the regular expression mode and available flag. It can also be a variable name or string text that contains the regular expression mode and available signs.

Description \\

If no match is found in the match method, null is returned. If a match is found, an array is returned and the attributes of the global RegExp object are updated to reflect the matching result.
Match
The array returned by the method has three attributes: input, index, and lastIndex. The Input attribute contains the entire searched string. Index
The attribute contains the position of the matched substring in the searched string. The LastIndex attribute contains the next position of the last character in the last match.
If no global flag is set
(G), the 0 element of the array contains the entire match, and the 1st to n element contains any child match that has occurred in the match. This is equivalent to exec with no global flag set.
Method. If a global flag is set, elements 0 to n contain all matches.

Example \\
The following example demonstrates the usage of the match method:
[Code]
Function MatchDemo () {var r, re; // declare the variable. Var s = "The rain in Spain falls
Mainly in the plain "; re =/ain/I; // create the regular expression mode. R = s. match (re); // try to match the search string.
Return (r); // return the place where "ain" appears for the first time. } [/Code]
Return Value: ain

This example describes
The usage of the match method.
[Code] function MatchDemo () {var r, re; // declare the variable. Var s ="
Rain in Spain falls mainly in the plain "; re =/ain/ig; // create the regular expression mode. R =
S. match (re); // try to match the search string. Return (r); // The returned array contains all the "ain" // four matching results. } [/Code]

Return Value: ain, ain

The above lines of code demonstrate the usage of the match Method for string text.
[Code] var r,
Re = "Spain"; r = "The rain in Spain". replace (re, "Canada"); return r; [/code]

Return Value: The rain in Canada

Search
Method
Returns the position of the first substring that matches the regular expression.

StringObj. search (rgExp)

Parameter \\
StringObj
Required. String object or String text to be searched.

RgExp

Required. A regular expression object that contains the regular expression mode and available flag.

Description

Search
Specifies whether a matching exists. If a match is found, the search method returns an integer indicating the offset position starting from the string. If no match is found,-1 is returned.

Example \\
The following example demonstrates how to use the search method.
[Code] function SearchDemo () {var
R, re; // declare the variable. Var s = "The rain in Spain falls mainly in the plain."; re =
/Falls/I; // create the regular expression mode. R = s. search (re); // search for strings. Return (r); // return the Boolean result.
} [/Code]
Return Value: 18

Regular expression syntax

A regular expression is composed of common characters (such as characters a
Z) and special characters (called metacharacters. This mode describes one or more strings to be matched when searching the text subject. A regular expression is used as a template to match a character pattern with the searched string.

Here are some examples of regular expressions that may be encountered:
[Code] JScript VBScript match/^ \ [\ t] * $/"^ \[
\ T] * $ "matches a blank row. /\ D {2}-\ d {5}/"\ d {2}-\ d {5}" verify that an ID number consists of two digits, A hyphen and a five-digit combination.
/<(. *)>. * <\/\ 1>/"<(. *)>. * <\/\ 1>" matches an HTML Tag. [/Code]

The following table shows a complete list of metacharacters and their behaviors in the context of a regular expression:

Character Description
\
Mark the next character as a special character, a literal character, a back reference, or an octal escape character. For example, 'n' matches the character "n ". '\ N' matches a line break. Sequence '\\'
Match "\" and "\ (" match "(".

^ Matches the start position of the input string. If the Multiline attribute of the RegExp object is set, ^
It also matches the location after '\ n' or' \ R.

$ Matches the end position of the input string. If the Multiline attribute of the RegExp object is set, $ also matches
'\ N' or' \ R.

* Matches the previous subexpression zero or multiple times. For example, zo * can match "z" and "zoo ". * Is equivalent to {0 ,}.

+ Match the previous subexpression once or multiple times. For example, 'Zo + 'can match "zo" and "zoo", but cannot match "z ". + Is equivalent to {1 ,}.

? Match the previous subexpression zero or once. For example, "do (es )? "Can match" do "in" do "or" does ".? It is equivalent to {0, 1 }.

{N} n is a non-negative integer. Match n times. For example, 'O {2} 'cannot match 'O' in "Bob", but can match two o in "food.

{N,} n is a non-negative integer. Match at least n times. For example, 'O {2,} 'cannot match 'O' in "Bob", but can match all
O. 'O {1,} 'is equivalent to 'o + '. 'O {0,} 'is equivalent to 'o *'.

Both {n, m} m and n are non-negative integers, where n <=
M. Match at least n times and at most m times. Liu, "o {1, 3}" will match the first three o in "fooooood. 'O {0, 1} 'is equivalent
'O? '. Note that there must be no space between a comma and two numbers.

? When this character is followed by any other delimiter (*, + ,?, {N}, {n ,}, {n, m })
Later, the matching mode is non-greedy. The non-Greedy mode matches as few searched strings as possible, while the default greedy mode matches as many searched strings as possible. For example, for strings "oooo", 'O ++? '
A single "o" will be matched, while 'o + 'will match all 'O '.

. Match any single character except "\ n. To match any character including '\ n', use the image
'[. \ N]' mode.
(Pattern) matches pattern and obtains this match. The obtained match can be obtained from the generated Matches set. In VBScript
Use the SubMatches set, and use $0… In JScript... $9 attribute. To match the parentheses, use '\ (' or '\)'.

(? : Pattern) matches pattern but does not get the matching result. That is to say, this is a non-get match and is not stored for future use. This is using the "or" character (|)
It is useful to combine all parts of a pattern. For example, 'industr (? : Y | ies) is a simpler expression than 'industry | industries.

(? = Pattern) Forward pre-query, in any match pattern
To start from the string. This is a non-get match, that is, the match does not need to be obtained for future use. For example, 'windows (? = 95 | 98 | NT | 2000) 'can match
"Windows" in "Windows 2000", but cannot match "Windows 3.1"
"Windows ". Pre-query does not consume characters, that is, after a match occurs, the next matching search starts immediately after the last match, instead of starting after the pre-query characters.

(?! Pattern) Negative pre-query, in any does not match Negative lookahead matches the search string
Any point where a string not matching pattern
To start from the string. This is a non-get match, that is, the match does not need to be obtained for future use. For example, 'windows (?! 95 | 98 | NT | 2000) 'can match
"Windows" in "Windows 3.1", but cannot match "Windows 2000"
"Windows ". Pre-query does not consume characters. That is to say, after a match occurs, the next matching search starts immediately after the last match, instead of starting after the pre-query characters.

X | y matches x or y. For example, 'z | food' can match "z" or "food ". '(Z | f) ood' matches "zood" or
"Food ".

[Xyz] Character Set combination. Match any character in it. For example, '[abc]' can match 'A' in "plain '.

[^ Xyz] combination of negative character sets. Match any character not included. For example, '[^ abc]' can match 'p' in "plain '.

[A-z]
Character range. Matches any character in the specified range. For example, '[a-z]' can match any lowercase letter in the range of 'A' to 'Z.

[^ A-z]
Negative character range. Matches any character that is not within the specified range. For example, '[^ a-z]' can match any character that is not in the range of 'A' to 'Z.

\ B
Match A Word boundary, that is, the position between a word and a space. For example, 'er \ B 'can match 'er' in "never", but cannot match 'er 'in "verb '.

\ B matches non-word boundaries. 'Er \ B 'can match 'er' in "verb", but cannot match 'er 'in "never '.

\ Cx
Match the control characters specified by x. For example, \ cM matches a Control-M or carriage return character. The value of x must be either a A-Z or a-z. Otherwise, c is treated as an original 'C'
Character.

\ D matches a numeric character. It is equivalent to [0-9].

\ D matches a non-numeric character. It is equivalent to [^ 0-9].

\ F
Match a form feed. It is equivalent to \ x0c and \ cL.

\ N matches a linefeed. It is equivalent to \ x0a and \ cJ.

\ R
Match a carriage return. It is equivalent to \ x0d and \ cM.

\ S matches any blank characters, including spaces, tabs, and page breaks. It is equivalent to [\ f \ n \ r \ t \ v].

\ S matches any non-blank characters. It is equivalent to [^ \ f \ n \ r \ t \ v].

\ T matches a tab. It is equivalent to \ x09 and \ cI.

\ V matches a vertical tab. It is equivalent to \ x0b and \ cK.

\ W
Match any word characters that contain underscores. It is equivalent to '[A-Za-z0-9 _]'.

\ W matches any non-word characters. It is equivalent to '[^ A-Za-z0-9 _]'.

\ Xn matches n, where n is the hexadecimal escape value. The hexadecimal escape value must be determined by the length of two numbers. For example, '\ x41' matches "". '\ X041' is equivalent
'\ X04' & "1 ". The regular expression can use ASCII encoding ..

\ Num matches num, where num
Is a positive integer. References to the obtained matching. For example, '(.) \ 1' matches two consecutive identical characters.

\ N identifies an octal escape value or a backward reference. If \ n
If there are at least n obtained subexpressions, n is a back reference. Otherwise, if n is an octal digit (0-7), n is an octal escape value.

\ Nm
Identifies an octal escape value or a backward reference. If there are at least is preceded by at least nm obtained subexpressions before \ nm, then nm is backward reference. If
If at least n records are obtained before \ nm, n is a backward reference followed by m. If none of the preceding conditions are met, if n and m are octal digits (0-7), then \ nm
Match the octal escape value nm.

\ Nml if n is an octal digit (0-3) and m and l are octal digits (0-7), the octal escape value is matched.
Nml.

\ Un matches n, where n is a Unicode character represented by four hexadecimal numbers. For example, \ u00A9 matches the copyright symbol (?).

Priority Order

After constructing a regular expression, you can evaluate the value like a mathematical expression, that is, you can evaluate the value from left to right in a priority order.

The following table lists the priority orders of various regular expression operators from the highest priority to the lowest priority:
[Code] OPERATOR description \ escape character (),(? :),
(? =), [] Parentheses and square brackets *, + ,?, {N}, {n ,}, {n, m} qualifier ^, $, \ anymetacharacter location and order |
"Or" operation [/code]

Common characters

A common character consists of all the print and non-print characters that are not explicitly specified as metacharacters. This includes all uppercase and lowercase letter characters, all numbers, all punctuation marks, and some symbols.

The simplest regular expression is a single normal character that can match the character itself in the searched string. For example, the single-Character Mode 'A' can match the letters at any position in the searched string.
'A '. Here are some examples of Single-character regular expression patterns:
[Code]/a // 7 // M/[/code]
Equivalent VBScript
The single-character regular expression is:
[Code] "a" "7" "M" [/code]
You can combine multiple single characters to obtain a large expression. For example
A JScript regular expression is an expression created by combining the single-character expressions 'A', '7', and 'M.

/A7M/
Equivalent
VBScript expression:

"A7M"
Note that there is no join operator here. All you need to do is place one character after the other.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.