Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
32 views

Regular Expression

Table 13.6 describes metacharacters and metasymbols used in regular expressions. It lists single character classes that match things like alphanumeric characters, digits, whitespace, and line anchors. It also describes repeated character classes that match things like 0 or more repetitions, 1 or more repetitions between a specified min and max, and backreferences to captured groups. Alternative character classes are listed that allow matching one of several options or establishing lookahead and lookbehind conditions without including the text in the match.

Uploaded by

Vidya Shree
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views

Regular Expression

Table 13.6 describes metacharacters and metasymbols used in regular expressions. It lists single character classes that match things like alphanumeric characters, digits, whitespace, and line anchors. It also describes repeated character classes that match things like 0 or more repetitions, 1 or more repetitions between a specified min and max, and backreferences to captured groups. Alternative character classes are listed that allow matching one of several options or establishing lookahead and lookbehind conditions without including the text in the match.

Uploaded by

Vidya Shree
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

Table 13.6. Metacharacters and metasymbols.

Metacharacter/Metasymbol Character Class: Single Characters and Digits . [az09] [^az09] \d \D \w \W \0 \b \f \n \r \s \S \t ^ $ \A \b \B \G \Z \z X?

What It Matches Matches any character except newline Matches any single character in set Matches any single character not in set Matches one digit Matches a non-digit, same as [^09] Matches an alphanumeric (word) character Matches a non-alphanumeric (non-word) character Matches a null character Matches a backspace Matches a formfeed Matches a newline Matches a return Matches whitespace character, spaces, tabs, and newlines Matches non-whitespace character Matches a tab Matches to beginning of line Matches to end of line Matches the beginning of the string only Matches a word boundary (when not inside [ ]) Matches a non-word boundary Matches where previous m//g left off Matches the end of the string or line Matches the end of string only Matches 0 or 1 of x

Character Class: Whitespace Characters

Character Class: Anchored Characters

Character Class: Repeated Characters

Table 13.6. Metacharacters and metasymbols.

Metacharacter/Metasymbol X* X+ (xyz)+ X{m,n} was|were|will (string) \1 or $1 \2 or $2 \3 or $3 New with JavaScript 1.5 (?:x)

What It Matches Matches 0 or more of x Matches 1 or more of x Matches one or more patterns of xyz Matches at least m of x and no more than n of x Matches one of was, were, or will Used for backreferencing (see "Remembering or Capturing" on page 443) Matches first set of parentheses Matches second set of parentheses Matches third set of parentheses Matches x but does not remember the match. These are called non-capturing parentheses. The matched substring cannot be recalled from the resulting array's elements [1], ..., [n] or from the predefined RegExp object's properties $1, ..., $9. Matches x only if x is followed by y. For example, /Jack(? =Sprat)/ matches Jack only if it is followed by >Sprat. /Jack(?=Sprat|Frost)/ matches Jack only if it is followed by Sprat or Frost. However, neither Sprat nor Frost are part of the match results. Matches x only if x is not followed by y. For example, /\d+(?!\.)/ matches a number only if it is not followed by a decimal point. /\d+(?!\.)/.exec("3.141") matches 141 but not 3.141.

Character Class: Alternative Characters Character Class: Remembered Characters

x(?=y)

x(?!y)

You might also like