0% found this document useful (0 votes)
47 views1 page

Metacharacters For Regular Expressions in Perl

This document summarizes the metacharacters used in regular expressions in Perl. It describes general metacharacters like . and |, character classes like \w and \d, anchors like ^ and $, quantifiers like ?, *, and +, and modifiers like i, x, and s. The document provides examples of how these metacharacters are used to match patterns in strings.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views1 page

Metacharacters For Regular Expressions in Perl

This document summarizes the metacharacters used in regular expressions in Perl. It describes general metacharacters like . and |, character classes like \w and \d, anchors like ^ and $, quantifiers like ?, *, and +, and modifiers like i, x, and s. The document provides examples of how these metacharacters are used to match patterns in strings.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Metacharacters for regular expressions in Perl

General metacharacters:
. any character (except \n)
( ) grouping, saving
\1, \2, etc. back-references to saved matches
| (pipe symbol) alternatives (generally inside parentheses)

Character classes:
[abcd], [A-Z] bracketed character class (any character in the bracket, within range)
[^abcd] negation of bracketed characters (any character not in the bracket)
\w any word character [A-Za-z0-9_]
\W any non-word character [^A-Za-z0-9_]
\d any digit [0-9]
\D any non-digit [^0-9]
\s any space character [\t\n\f\r ]
\S any non-space character [^\t\n\f\r ]

Anchors:
^ match start of string
$ match end of string
\b word boundary
\B non-word boundary

Quantifiers:
? 0 or 1
* 0 or more
+ 1 or more
{m,n} between m and n
{m,} at least m
{m} exactly m
Greediness of these quantifiers is turned off by a trailing "?" character:
??, *?, +?, {m,n}?, {m,}?

Modifiers:
i make matching case-insensitive
x ignore spaces (and newlines) in pattern
s also match \n for . in pattern
g match the complete string (continue searching after the first match)
Modifiers are entered after the pattern:
/pattern/ixsg

You might also like