Basic JS Regular Expressions (Classic full) and js Regular Expressions

Source: Internet
Author: User

Basic JS Regular Expressions (Classic full) and js Regular Expressions

// Check whether it is composed of digits

Funtin isigit (s) {var patrn =/^ [0-9] {1, 20} $/; if (! Patrn. x (s) rturn fals rturn tru}

Use the regular expression to verify mail and determine whether the input is email mail.

// Check the mail mailbox

Funtin ismail (str ){
Var rg =/^ ([a-zA-Z0-9 _-]) + @ ([a-zA-Z0-9 _-]) + ((\. [a-zA-Z0-9 _-] {2, 3}) {1, 2}) $ /;
Rturn rg. tst (str );
}

// Check Logon Name: You can enter only 5-20 strings starting with a letter, which can contain numbers, "_", and ".".

Funtin isrgistrusnam (s) {var patrn =/^ [a-zA-Z] {1} ([a-zA-Z0-9] | [. _]) {4, 19} $/; if (! Patrn. x (s) rturn fals rturn tru}

// Check user name: only 1-30 strings starting with letters can be entered

Funtin isTruNam (s) {var patrn =/^ [a-zA-Z] {1, 30} $/; if (! Patrn. x (s) rturn fals rturn tru }}}

// Password verification: only 6-20 letters, numbers, and underscores can be entered

Funtin isPassw (s) {var patrn =/^ (\ w) {6, 20} $/; if (! Patrn. x (s) rturn fals rturn tru}

// Verify the phone number and fax number. The phone number can start with "+" and contain "-" in addition to numbers.
Funtin isTl (s) {// var patrn =/^ [+] {0, 1} (\) {1, 3} []? ([-]? (\) {}) + $/; Var patrn =/^ [+] {} (\) {} []? ([-]? (\) | []) {1, 12}) + $/; if (! Patrn. x (s) rturn fals rturn tru}

// Verify the mobile phone number. It must start with a number and can contain "-" in addition to a number.

Funtin isMbil (s) {var patrn =/^ [+] {0, 1} (\) {1, 3} []? ([-]? (\) | []) {1, 12}) + $/; if (! Patrn. x (s) rturn fals rturn tru}

// Verify the zip code

Funtin isPstal (s) {// var patrn =/^ [a-zA-Z0-9] {} $/; var patrn =/^ [a-zA-Z0-9] {} $/; if (! Patrn. x (s) rturn fals rturn tru}

// Verify the search keyword

Funtin isSarh (s) {var patrn =/^ [^ '~! @ # $ % ^ & * () + = |\\] [\] \{\}:;' \,. <>/?] {1} [^ '~! @ $ % ^ & () + =|\\] [\] \{\}:; '\,. <>?] {0, 19} $/; if (! Patrn. x (s) rturn fals rturn tru} funtin isIP (s) // by zrgling {var patrn =/^ [0-9.] {1, 20} $/; if (! Patrn. x (s) rturn fals rturn tru}

Regular Expression

"^ \ + $"

// Non-negative integer (positive integer + 0)

"^ [0-9] * [1-9] [0-9] * $"

// Positive integer "^ (-\ +) | (0 +) $"

// Non-positive integer (negative integer + 0)

"^-[0-9] * [1-9] [0-9] * $"

// Negative integer "^ -? \ + $"

// Integer "^ \ + (\. \ + )? $"

// 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 "^ (-\\+ (\\. \\+ )?) | (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

"^ (-? \\+) (\\. \\+ )? $"

// Floating point number "^ [A-Za-z] + $"

// A string consisting of 26 English letters

"^ [A-Z] + $"

// A string consisting of 26 uppercase letters

"^ [A-z] + $"

// A string consisting of 26 lower-case letters

"^ [A-Za-z0-9] + $"

// A string consisting of a number and 26 English letters

"^ \ W + $"

// A string consisting of digits, 26 English letters, or underscores

"^ [\ W-] + (\\. [\ w-] +) * @ [\ w-] + (\\. [\ w-] +) + $"

// Mail address

"^ [A-zA-z] +: // (\ w + (-\ w + )*)(\\. (\ w + (-\ w + )*))*(\\? \ S *)? $"

// Url "^ [A-Za-z0-9 _] * $"

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:

/Lv/

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.

/F +/because the regular expression above contains the "+" metacharacter, it can be used with the "fl", "f ", or "ftball" and so on. One or more character strings appear consecutively after the letter "f.

/G */because the above regular expression contains "*" metacharacters, it can be used with "asy", "g ", or, "gg" and other strings with zero or more letters, g, consecutively after the letter match.

/Wil? /Because the above regular expression contains "?" Metacharacter, indicating that it can match the "Win" or "Wilsn" in the target object, and matches zero or one character string after the letter I.

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, '{2}' cannot match ''in" Bb ", but can match two in" f.

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

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, "{1, 3}" matches the first three in "f. '{0, 1}' is equivalent '? '. 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, the/jim {}/regular expression specifies that the character m can appear 2-6 times in a row in the matching object. Therefore, the regular expression can match strings such as jimmy or jimmmmmy.

After a preliminary understanding of how to use regular expressions, let's take a look at the usage of several other important metacharacters.
\ 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; \: 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.

(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.

/\ 000/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 ".

The "^" operator specifies that the matching mode must appear at the beginning of 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 is required. the "\ B" locator, one of the two boundaries at the beginning or end of the target string, specifies that the matching object must be within the two boundaries at the beginning and end of the target string, that is, the matched object cannot start or end with the target string.

Similarly, we can regard "^" and "$" as well as "\ B" and "\ B" as two sets of operators for inverse operation. For example:/^ hll/because the above regular expression contains the "^" locator, you can use "hll" with the target object ", the string starting with "hll" or "hllhun" matches. /Ar $/because the regular expression above contains the "$" operator, it can match the string ending with "ar", "bar", or "ar" in the target object. /\ Bbm/because the above regular expression pattern starts with "\ B", it can match a string starting with "bmb" or "bm" in the target object. /Man \ B/because the above regular expression pattern ends with the "\ B" positioning character, you can use "human" with the target object ", the string ending with "wman" or "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:
/[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.

Note that you can use "()" in a regular expression to combine strings. The content contained by the "()" symbol must appear in the target object at the same time. Therefore, the above regular expression cannot match strings such as "AB", because the last character in "AB" is a letter rather than a number.
If we want to implement the "or" operation similar to the programming logic in the regular expression, and select one of multiple different modes for matching, we can use the pipe character "| ". For example,/t | 2/the above regular expression will match "t", "t", or "2" in the target object.

There is also a common operator in the regular expression, that is, the negative character "[^]". Unlike the positioning character "^" described above, the "[^]" negation specifies that the target object cannot contain strings specified in the pattern. For example,/[^ A-]/the above string will match any character except A, B, and in the target object. In general, when "^" appears in "", it is regarded as a negative operator. When "^" is outside of "", or there is no, 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. For example, the/Th \ */regular expression will match the "Th *" rather than "Th" in the target object.

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:

1. \ Escape Character 2 .(),(? :),(? =), Parentheses and square brackets 3. *, + ,?, {N}, {n ,}, {n, m} qualifier 4. ^, $, \ anymtaharach position and sequence 5. | "or" Operation

Use instance

The regular expression 1.2 contains a powerful Rgxp () object that can be used to match regular expressions. The tst () method can check whether the target object contains a matching pattern and return tru or fals accordingly.
You can use JavaSript to write the following script to verify the validity of the email address entered by the user.

Regular Expression object

This object contains the regular expression mode and a flag indicating how to apply the mode.

Syntax 1 r =/pattrn/[flags] syntax 2 r = nw Rgxp ("pattrn", ["flags"])

Parameters

R

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

Pattrn

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:

G (all pattrn in full-text search) I (case-insensitive) m (multi-row search)

Example

The following example creates an object (r) that contains the Regular Expression Pattern and related signs to demonstrate the usage of the regular expression object. In this example, the regular expression used as the result

The object is also used in the math method:

Funtin Mathm () {var r, r; // declare the variable. Var s = "Th rain in Spain falls mainly in th plain"; r = nw Rgxp ("ain", "g"); // create a regular expression object. R = s. math (r); // search for matching in string s. Rturn (r );}

Return Value: ain, ain \\

Property lastInx property | sur property \\

Method mpil method | x method | tst Method \\

Required version 3 \\

See Rgxp object | regular expression syntax | String object \\

X Method

Run the search in the string in regular expression mode and return an array containing the search result.

Rgxp. x (str)

Parameters

Rgxp

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

Str

Required. The String object or String text to be searched.

Description \\

If the x method does not find a match, it returns null. If it finds a match, the x method returns an array and updates the attributes of the global Rgxp object to reflect the matching result. 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 the math method without setting the global flag.

If a global flag is set for the regular expression, x searches for it starting from the position indicated by the value of lastInx. If the global flag is not set, x ignores the value of lastInx and searches from the starting position of the string.

The array returned by the x method has three attributes: input, struct, and lastInx. The Input attribute contains the entire searched string. The substring attribute contains the position of the matched substring in the searched string. The LastInx attribute contains the next position of the last character in the match.

Example \\

The following example illustrates the usage of the x method:

Funtin RgxpTst () {var vr = Numbr (SriptnginMajrVrsin () + "." + SriptnginMinrVrsin () if (vr >=5.5 ){

// Test the JSript version.

Var sr = "Th rain in Spain falls mainly in th plain."; var r =/\ w +/g;

// Create the regular expression mode.

Var arr; whil (arr = r. x (sr ))! = Null) umnt. writ (arr. role + "-" + arr. lastInx + arr + "\ t");} ls {alrt ("Please use the updated version of JSript ");}}

Return Value: 0-3Th 4-8rain 9-11in 12-17Spain 18-23falls 24-30mainly 31-33in 34-37th 38-43plain

Tst Method

\ Returns a Blan value indicating whether the pattern exists in the searched string.

Rgxp. tst (str)

Parameter \\

Rgxp

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

Str

Required. The string to be searched.

Description

The tst method checks whether a mode exists in the string. If yes, tru is returned; otherwise, fals is returned.

The attributes of the global Rgxp object cannot be modified by the tst method.

Example

The following example illustrates the usage of the tst method:

Funtin Tstm (r, s) {var s1; // declare the variable.

// Check whether a regular expression exists in the string.

If (r. tst (s ))

// Test whether the API exists.

S1 = "ntains ";

// S inclusion mode. Ls s1 = "s nt ntain ";

// S does not contain the mode. Rturn ("'" + s + "'" + s1 + "'" + r. sur + "'");

// Returns a string. }

Function call: umnt. writ (Tstm (/ain +/, "Th rain in Spain falls mainly in th plain ."));

Returned value: 'th rain in Spain falls mainly in Th plain. 'ntains' ain +'

Math Method

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

\ Stringbj. math (rgxp)

Parameters

\ Stringbj is required. String object or String text to search.

Rgxp

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 for the math method, null is returned. If a match is found, an array is returned and the attributes of the global Rgxp object are updated to reflect the matching result.
The array returned by the math method has three attributes: input, struct, and lastInx. The Input attribute contains the entire searched string. The substring attribute contains the position of the matched substring in the searched string. The LastInx attribute contains the next position of the last character in the last match.

If the global sign (g) is not set, the 0 element of the array contains the entire match, and the 1st to n element contains any child match that has occurred during the match. This is equivalent to the x method without a global flag. If a global flag is set, elements 0 to n contain all matches.

Example \

\ The following example demonstrates the usage of the math method:
Funtin Mathm () {var r, r; // declare the variable.

Var s = "Th rain in Spain falls mainly in th plain"; r =/ain/I; // create the regular expression mode. R = s. math (r );

// Try to match the search string. Rturn (r );

// Return the first occurrence of "ain. }
Return Value: ain

This example describes how to use the math method with g flag settings.
Funtin Mathm () {var r, r; // declare the variable.

Var s = "Th rain in Spain falls mainly in th plain"; r =/ain/ig;

// Create the regular expression mode. R = s. math (r );

// Try to match the search string. Rturn (r );

// The returned array contains all the "ain" // four matching results. }
Return Value: ain, ain

The above lines of code demonstrate the usage of the math method for string text.

Var r, r = "Spain"; r = "Th rain in Spain". rpla (r, "anaa"); rturn r;

Returned value: Th rain in anaa

Sarh Method

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

Stringbj. sarh (rgxp)

Parameters

\ Stringbj
Required. String object or String text to be searched.

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

Description

The sarh method specifies whether a matching exists. If a match is found, the sarh 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 the use of the sarh method.
Funtin Sarhm () {var r, r; // declare the variable. Var s = "Th rain in Spain falls mainly in th plain."; r =/falls/I; // create a regular expression pattern. R = s. sarh (r); // search for strings. Rturn (r); // return the Blan result. }
Return Value: 18

Regular expression syntax

A regular expression is a text mode consisting of common characters (such as characters a to z) and special characters (such as 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:

Match/^ \ [\ t] * $/"^ \ [\ t] * $" with a blank line. /\ {2}-\ {5}/"\ {2}-\ {5}" verify that an I number is composed of two digits, A hyphen and a five-digit combination. /<(. *)>. * <\/\ 1>/"<(. *)>. * <\/\ 1>" matches an HTML Tag.

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. The sequence '\' matches "" and "\ (" matches "(".

^ Matches the start position of the input string. If the Multilin attribute of the Rgxp object is set, ^ matches the position after '\ n' or' \ R.

$ Matches the end position of the input string. If the Multilin attribute of the Rgxp object is set, $ also matches the position before '\ n' or' \ R.

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

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

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

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

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

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

? When this character is followed by any other delimiter (*, + ,?, The matching mode after {n}, {n ,}, {n, m}) is not 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 a string "", '+? 'Will match a single "", and' + 'will match all ''.

. Match any single character except "\ n. To match any character including '\ n', use a pattern like' [. \ n.
(Pattrn) matches pattrn and obtains this match. The obtained match can be obtained from the generated Maths set. The SubMaths set is used in VBSript and $0... $9 attribute. To match the parentheses, use '\ (' or '\)'.

(? : Pattrn) matches pattrn 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 useful when you use the "or" character (|) to combine each part of a pattern. For example, 'inustr (? : Y | is) is a simpler expression than 'inustry | inustris.

(? = Pattrn) Forward pre-query: matches the search string at the beginning of any string that matches pattrn. This is a non-get match, that is, the match does not need to be obtained for future use. For example, 'winws (? = 95 | 98 | NT | 2000) 'can match "Winws" in "Winws 2000", but cannot match "Winws" in "Winws 3.1 ". 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.

(?! Pattrn) negative pre-query, match the search string at the start of any string that does not match Ngativ lkaha maths th sarh string at any pint whr a string nt mathing pattrn. This is a non-get match, that is, the match does not need to be obtained for future use. For example, 'winws (?! 95 | 98 | NT | 2000) 'can match "Winws" in "Winws 3.1", but cannot match "Winws" in "Winws 2000 ". 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 | f' can match "z" or "f ". '(Z | f)' matches "z" or "f ".

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

[^ Xyz] combination of negative character sets. Match any character not included. For example, '[^ AB]' 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 matches a word boundary, that is, the position between a word and a space. For example, 'r \ B 'can match 'R' in "nvr", but cannot match 'R' in "vrb '.

\ B matches non-word boundaries. 'R \ B 'can match 'R' in "vrb", but cannot match 'R' in "nvr '.

\ X matches the control characters specified by x. For example, \ M matches an ntrl-M or carriage return. The value of x must be either a A-Z or a-z. Otherwise, it is treated as a ''character.

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

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

\ F matches a break. It is equivalent to \ x0 and \ L.

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

\ R matches a carriage return. It is equivalent to \ x0 and \ M.

\ 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 \ I.

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

\ W matches 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 to '\ x04' & "1 ". The regular expression can use ASII 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 at least n subexpressions are obtained before \ n, n is a backward 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 pr by at last nm obtained subexpressions before \ nm, then nm is backward reference. If at least n records are obtained before \ nm, n is a backward reference followed by text m. If none of the preceding conditions are met, if n and m are Octal numbers (0-7), \ nm matches the octal escape value nm.

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

\ Un matches n, where n is a Uni 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:
Operator description \ escape character (),(? :),(? =), Parentheses and square brackets *, + ,?, {N}, {n ,}, {n, m} qualifier ^, $, \ anymtaharrecognition position and sequence | "or" Operation

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 'A' letter that appears at any position in the searched string '. Here are some examples of Single-character regular expression patterns:
/A // 7 // M/
The following is an equivalent single-character regular expression:
"A" "7" "M"
You can combine multiple single characters to obtain a large expression. For example, the following regular expression is a combination of Single-character expressions 'A', '7', and 'M.

/A7M/
The equivalent VBSript expression is:

"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.