Perl defines an extended syntax for regular expressions. The syntax is a pair of parentheses with a question mark as the first thing within the parentheses. The character after the question mark gives the function of the extension. The extensions are:
(?#
text
)
A comment. The text is ignored.
(?:...)
(?imsx-imsx:...)
This groups things like (...)
but doesn’t make
backreferences.
(?=...)
A zero-width positive lookahead assertion. For example,
/w+(?= )/
matches a word
followed by a tab, without including the tab in $&
.
(?!...)
A zero-width negative lookahead assertion. For example,
/foo(?!bar)/
matches any
occurrence of foo
that
isn’t followed by bar
.
(?<...)
A zero-width positive lookbehind assertion. For example,
/(?<bad)boy/
matches the
word boy
that follows
bad
, without including
bad
in $&
. This works only for
fixed-width lookbehind.
(?{
code
})
An experimental regular expression feature to evaluate
any embedded Perl code. This evaluation always succeeds, and
code
is not interpolated.
(?<!=...)
A zero-width negative lookbehind assertion. For example,
/(?<!=bad)boy/
matches
any occurrence of boy
that
doesn’t follow bad
. This
works only for fixed-width lookbehind.
(?>...)
Matches the substring that the standalone pattern would match if anchored at the given position.
(?(
condition
)
yes-pattern
|no-pattern
)
(?(
condition
)yes-pattern
)
Matches a pattern determined by a condition.
condition
should be either an
integer, which is true if the pair of parentheses
corresponding to the integer has matched, or a lookahead,
lookbehind, or evaluate, zero-width assertion.
no-pattern
will be used to match if
the condition was not meant, but it is also optional.
(?imsx-imsx)
One or more embedded pattern-match modifiers. Modifiers
are switched off if they follow a -
(dash). The modifiers are defined
as follows :
3.144.115.154