1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353
|
<HTML
><HEAD
><TITLE
>Pattern Modifiers</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.57"><LINK
REL="HOME"
TITLE="PHP Manual"
HREF="manual.html"><LINK
REL="UP"
TITLE="Regular Expression Functions (Perl-Compatible)"
HREF="ref.pcre.html"><LINK
REL="PREVIOUS"
TITLE="preg_grep"
HREF="function.preg-grep.html"><LINK
REL="NEXT"
TITLE="Pattern Syntax"
HREF="pcre.pattern.syntax.html"><META
NAME="HTTP_EQUIV"
CONTENT="text/html; charset=ISO-8859-1"></HEAD
><BODY
CLASS="refentry"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>PHP Manual</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.preg-grep.html"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="pcre.pattern.syntax.html"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="pcre.pattern.modifiers"
>Pattern Modifiers</A
></H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN33102"
></A
><P
> (unknown)</P
>Pattern Modifiers -- Describes possible modifiers in regex
patterns</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN33105"
></A
><H2
>Description</H2
><P
> The current possible PCRE modifiers are listed below. The names
in parentheses refer to internal PCRE names for these modifiers.
</P
><P
> <A
NAME="AEN33109"
></A
><BLOCKQUOTE
CLASS="BLOCKQUOTE"
><P
></P
><DIV
CLASS="variablelist"
><DL
><DT
><I
CLASS="emphasis"
>i</I
> (PCRE_CASELESS)</DT
><DD
><P
> If this modifier is set, letters in the pattern match both
upper and lower case letters.
</P
></DD
><DT
><I
CLASS="emphasis"
>m</I
> (PCRE_MULTILINE)</DT
><DD
><P
> By default, PCRE treats the subject string as consisting of a
single "line" of characters (even if it actually contains
several newlines). The "start of line" metacharacter (^)
matches only at the start of the string, while the "end of
line" metacharacter ($) matches only at the end of the
string, or before a terminating newline (unless
<I
CLASS="emphasis"
>E</I
> modifier is set). This is the same as
Perl.
</P
><P
> When this modifier is set, the "start of line" and "end of
line" constructs match immediately following or immediately
before any newline in the subject string, respectively, as
well as at the very start and end. This is equivalent to
Perl's /m modifier. If there are no "\n" characters in a
subject string, or no occurrences of ^ or $ in a pattern,
setting this modifier has no effect.
</P
></DD
><DT
><I
CLASS="emphasis"
>s</I
> (PCRE_DOTALL)</DT
><DD
><P
> If this modifier is set, a dot metacharater in the pattern
matches all characters, including newlines. Without it,
newlines are excluded. This modifier is equivalent to Perl's
/s modifier. A negative class such as [^a] always matches a
newline character, independent of the setting of this
modifier.
</P
></DD
><DT
><I
CLASS="emphasis"
>x</I
> (PCRE_EXTENDED)</DT
><DD
><P
> If this modifier is set, whitespace data characters in the
pattern are totally ignored except when escaped or inside a
character class, and characters between an unescaped #
outside a character class and the next newline character,
inclusive, are also ignored. This is equivalent to Perl's /x
modifier, and makes it possible to include comments inside
complicated patterns. Note, however, that this applies only
to data characters. Whitespace characters may never appear
within special character sequences in a pattern, for example
within the sequence (?( which introduces a conditional
subpattern.
</P
></DD
><DT
><I
CLASS="emphasis"
>e</I
></DT
><DD
><P
> If this modifier is set, <A
HREF="function.preg-replace.html"
><B
CLASS="function"
>preg_replace()</B
></A
>
does normal substitution of \\ references in the
replacement string, evaluates it as PHP code, and uses the
result for replacing the search string.
</P
><P
> Only <A
HREF="function.preg-replace.html"
><B
CLASS="function"
>preg_replace()</B
></A
> uses this modifier;
it is ignored by other PCRE functions.
</P
></DD
><DT
><I
CLASS="emphasis"
>A</I
> (PCRE_ANCHORED)</DT
><DD
><P
> If this modifier is set, the pattern is forced to be
"anchored", that is, it is constrained to match only at the
start of the string which is being searched (the "subject
string"). This effect can also be achieved by appropriate
constructs in the pattern itself, which is the only way to
do it in Perl.
</P
></DD
><DT
><I
CLASS="emphasis"
>D</I
> (PCRE_DOLLAR_ENDONLY)</DT
><DD
><P
> If this modifier is set, a dollar metacharacter in the pattern
matches only at the end of the subject string. Without this
modifier, a dollar also matches immediately before the final
character if it is a newline (but not before any other
newlines). This modifier is ignored if <I
CLASS="emphasis"
>m</I
>
modifier is set. There is no equivalent to this modifier in
Perl.
</P
></DD
><DT
><I
CLASS="emphasis"
>S</I
></DT
><DD
><P
> When a pattern is going to be used several times, it is
worth spending more time analyzing it in order to speed up
the time taken for matching. If this modifier is set, then
this extra analysis is performed. At present, studying a
pattern is useful only for non-anchored patterns that do not
have a single fixed starting character.
</P
></DD
><DT
><I
CLASS="emphasis"
>U</I
> (PCRE_UNGREEDY)</DT
><DD
><P
> This modifier inverts the "greediness" of the quantifiers so
that they are not greedy by default, but become greedy if
followed by "?". It is not compatible with Perl. It can also
be set by a (?U) modifier setting within the pattern.
</P
></DD
><DT
><I
CLASS="emphasis"
>X</I
> (PCRE_EXTRA)</DT
><DD
><P
> This modifier turns on additional functionality of PCRE that
is incompatible with Perl. Any backslash in a pattern that
is followed by a letter that has no special meaning causes
an error, thus reserving these combinations for future
expansion. By default, as in Perl, a backslash followed by a
letter with no special meaning is treated as a literal.
There are at present no other features controlled by this
modifier.
</P
></DD
></DL
></DIV
></BLOCKQUOTE
>
</P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="function.preg-grep.html"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="manual.html"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="pcre.pattern.syntax.html"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>preg_grep</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.pcre.html"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Pattern Syntax</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>
|