Perl Mode



Grouping

(
Start a group or back reference.
(?:
Pure grouping only.
(?=
Grouping with a positive lookahead.
(?!
Grouping with a negative lookahead.
(?i
Grouping with case-insensitive matching.
(?m
Grouping with multi-line matching.
(?s
Grouping with single line matching.
(?x
Grouping with free formatting.
(?#
Grouping comment.
|
Alternate (or) - a|b|c matches either a or b or c.
)
End a group or back reference.

Quantifiers

{
Start Min required, Max allowed set.
,
Insert comma - {min,max} separator.
}
End greedy Min required, Max allowed set.
}?
End non-greedy Min required, Max allowed set.
.
Match anything except the newline character.
?
Greedy one match allowed, but its optional.
*
Greedy zero or more matches allowed.
+
Greedy one match required, additional are optional.
??
Non-greedy one match allowed, but its optional.
*?
Non-greedy zero or more matches allowed.
+?
Non-greedy one match required, additional are optional.

Anchors

^
Insert start of line anchor.
\b
Insert a word anchor.
\B
Insert a non-word anchor.
\A
Insert a start of string anchor.
$
Insert end of line anchor.
\Z
Insert an end of string anchor.
\G
Insert an end of previous match anchor.

Modification

\l
Lower the case of the next character.
\u
Raise the case of the next character.
\L
Lower the case of text until optional \E.
\U
Raise the case of text until optional \E.
\Q
Add an escape before all non-alpha until \E.
\u\L
Capitalize first character, lower the rest until \E.
\l\U
Lowercase first character, raise the rest until \E.
\E
Insert an end mark for text modification.

Classes

.
Match anything except the newline character.
[
Start a character class.
[^
Start a negated character class.
]
Close a character class.
-
Create a character range like a-h.
a-z
Lowercase letter group.
A-Z
Uppercase letter group.
0-9
Match any digit group.

Variables

$_
Insert the default search target.
$1
Variable which stores the 1st matched text.
$2
Variable which stores the 2nd matched text.
$3
Variable which stores the 3rd matched text.
$+
Highest filled of $1, $2, ...
$`
Text before the match.
$&
Text of the match.
$'
Text after the match.

Operator

=~
Insert a target of regular expression operator.
!~
Insert a target of regular expression operator.
m/
Insert the match regular expression operator.
s/
Insert the substitute regular expression operator.
/
Used with m/ and s/, or anything you need it for.
split(
Split regular expression operator.
)
Close up the split operator.
/x
Remove comments and whitespace from regex.
/o
Compile regex just once.
/s
Single line mode for ^ and $.
/m
Multi-line match mode.
/i
Perform a case insensitive match.
/g
Modify the starting position of the match.
/e
Equivalent to placing eval{..} on substitution s/ / /.
#
Insert a comment marker.

Shorthand

\b
Match the backspace character.
\t
Match the tab character.
\n
Match the newline character.
\r
Match the carriage return.
\f
Match the form-feed character.
\a
Match the alarm (bell) character.
\e
Match the escape sequence character.
\o
Match character specified by the octal number o.
\x
Match character specified by the hex number x.
\c
Match the control character specified by char.
\w
Shorthand for a word - [a-zA-Z0-9_].
\W
Inverse of \\w.
\s
Shorthand for whitespace - [ \f\n\r\t].
\S
Inverse of \s.
\d
Shorthand for digits - [0-9].
\D
Inverse of \d.


Index