File: pattern.modifiers.xml

package info (click to toggle)
php-doc 20061001-1
  • links: PTS
  • area: non-free
  • in suites: etch, etch-m68k
  • size: 45,764 kB
  • ctags: 1,611
  • sloc: xml: 502,485; php: 7,645; cpp: 500; makefile: 297; perl: 161; sh: 141; awk: 28
file content (212 lines) | stat: -rw-r--r-- 8,074 bytes parent folder | download
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
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.8 $ -->
<!-- splitted from ./en/functions/pcre.xml, last change in rev 1.2 -->
<refentry id="reference.pcre.pattern.modifiers">
 <refnamediv>
  <refname>Pattern Modifiers</refname>
  <refpurpose>Describes possible modifiers in regex
   patterns</refpurpose>
 </refnamediv>
 <refsect1>
  <title>Description</title>
  <para>
   The current possible PCRE modifiers are listed below.  The names
   in parentheses refer to internal PCRE names for these modifiers.
   Spaces and newlines are ignored in modifiers, other characters cause error.
  </para>
  <para>
   <blockquote>
    <variablelist>
     <varlistentry>
      <term><emphasis>i</emphasis> (PCRE_CASELESS)</term>
      <listitem>
       <simpara>
        If this modifier is set, letters in the pattern match both
        upper and lower case letters.
       </simpara>
      </listitem>
     </varlistentry>
     <varlistentry>
      <term><emphasis>m</emphasis> (PCRE_MULTILINE)</term>
      <listitem>
       <simpara>
        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
        <emphasis>D</emphasis> modifier is set). This is the same as
        Perl.
       </simpara>
       <simpara>
        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.
       </simpara>
      </listitem>
     </varlistentry>
     <varlistentry>
      <term><emphasis>s</emphasis> (PCRE_DOTALL)</term>
      <listitem>
       <simpara>
        If this modifier is set, a dot metacharacter 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.
       </simpara>
      </listitem>
     </varlistentry>
     <varlistentry>
      <term><emphasis>x</emphasis> (PCRE_EXTENDED)</term>
      <listitem>
       <simpara>
        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.
       </simpara>
      </listitem>
     </varlistentry>
     <varlistentry>
      <term><emphasis>e</emphasis></term>
      <listitem>
       <simpara>
        If this modifier is set, <function>preg_replace</function>
        does normal substitution of backreferences in the
        replacement string, evaluates it as PHP code, and uses the
        result for replacing the search string.
        Single and double quotes are escaped by backslashes in substituted
         backreferences.
       </simpara>
       <para>
        Only <function>preg_replace</function> uses this modifier;
        it is ignored by other PCRE functions.
        <note>
         <simpara>
          This modifier was not available in PHP 3.
         </simpara>
        </note>
       </para>
      </listitem>
     </varlistentry>
     <varlistentry>
      <term><emphasis>A</emphasis> (PCRE_ANCHORED)</term>
      <listitem>
       <simpara>
        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.
       </simpara>
      </listitem>
     </varlistentry>
     <varlistentry>
      <term><emphasis>D</emphasis> (PCRE_DOLLAR_ENDONLY)</term>
      <listitem>
       <simpara>
        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 <emphasis>m</emphasis>
        modifier is set. There is no equivalent to this modifier in
        Perl.
       </simpara>
      </listitem>
     </varlistentry>
     <varlistentry>
      <term><emphasis>S</emphasis></term>
      <listitem>
       <simpara>
        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.
       </simpara>
      </listitem>
     </varlistentry>
     <varlistentry>
      <term><emphasis>U</emphasis> (PCRE_UNGREEDY)</term>
      <listitem>
       <simpara>
        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)
        <link linkend="regexp.reference.internal-options">modifier setting within
        the pattern</link> or by a question mark behind a quantifier (e.g.
        <literal>.*?</literal>).
       </simpara>
      </listitem>
     </varlistentry>
     <varlistentry>
      <term><emphasis>X</emphasis> (PCRE_EXTRA)</term>
      <listitem>
       <simpara>
        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.
       </simpara>
      </listitem>
     </varlistentry>
     <varlistentry>
      <term><emphasis>u</emphasis> (PCRE_UTF8)</term>
      <listitem>
       <simpara>
        This modifier turns on additional functionality of PCRE that
        is incompatible with Perl. Pattern strings are treated as
        UTF-8. This modifier is available from PHP 4.1.0 or greater
        on Unix and from PHP 4.2.3 on win32.
        UTF-8 validity of the pattern is checked since PHP 4.3.5.
       </simpara>
      </listitem>
     </varlistentry>
    </variablelist>
   </blockquote>
  </para>
 </refsect1>
</refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->