2003-10-22 19:52:45 +00:00
|
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
2004-07-29 10:15:26 +00:00
|
|
|
<!-- $Revision: 1.12 $ -->
|
2002-04-15 00:12:54 +00:00
|
|
|
<reference id="ref.pcre">
|
2003-10-22 19:52:45 +00:00
|
|
|
<title>Regular Expression Functions (Perl-Compatible)</title>
|
2002-04-15 00:12:54 +00:00
|
|
|
<titleabbrev>PCRE</titleabbrev>
|
|
|
|
|
|
|
|
<partintro>
|
2002-07-28 14:33:12 +00:00
|
|
|
<section id="pcre.intro">
|
|
|
|
&reftitle.intro;
|
|
|
|
<para>
|
2003-10-22 19:52:45 +00:00
|
|
|
The syntax for patterns used in these functions closely resembles
|
|
|
|
Perl. The expression should be enclosed in the delimiters, a
|
|
|
|
forward slash (/), for example. Any character can be used for
|
|
|
|
delimiter as long as it's not alphanumeric or backslash (\). If
|
|
|
|
the delimiter character has to be used in the expression itself,
|
|
|
|
it needs to be escaped by backslash. Since PHP 4.0.4, you can also use
|
|
|
|
Perl-style (), {}, [], and <> matching delimiters.
|
2004-07-29 10:15:26 +00:00
|
|
|
See <link linkend="reference.pcre.pattern.syntax">Pattern Syntax</link>
|
2004-03-02 12:50:22 +00:00
|
|
|
for detailed explanation.
|
2002-07-28 14:33:12 +00:00
|
|
|
</para>
|
|
|
|
<para>
|
2003-10-22 19:52:45 +00:00
|
|
|
The ending delimiter may be followed by various modifiers that
|
|
|
|
affect the matching.
|
2004-07-29 10:15:26 +00:00
|
|
|
See <link linkend="reference.pcre.pattern.modifiers">Pattern
|
|
|
|
Modifiers</link>.
|
2002-07-28 14:33:12 +00:00
|
|
|
</para>
|
|
|
|
<para>
|
2003-10-22 19:52:45 +00:00
|
|
|
PHP also supports regular expressions using a POSIX-extended syntax
|
2004-02-22 20:26:49 +00:00
|
|
|
using the <link linkend="ref.regex">POSIX-extended regex functions</link>.
|
2002-07-28 14:33:12 +00:00
|
|
|
</para>
|
2004-02-22 20:26:49 +00:00
|
|
|
<warning>
|
|
|
|
<para>
|
|
|
|
You should be aware of some limitations of PCRE. Read <ulink
|
|
|
|
url="&url.pcre.man;">&url.pcre.man;</ulink> for more info.
|
|
|
|
</para>
|
|
|
|
</warning>
|
2002-07-28 14:33:12 +00:00
|
|
|
</section>
|
2002-04-15 00:12:54 +00:00
|
|
|
|
|
|
|
<section id="pcre.requirements">
|
2002-07-28 14:33:12 +00:00
|
|
|
&reftitle.required;
|
2002-04-15 00:12:54 +00:00
|
|
|
<para>
|
2003-10-22 19:52:45 +00:00
|
|
|
Regular expression support is provided by the PCRE library
|
|
|
|
package, which is open source software, written by Philip Hazel,
|
|
|
|
and copyright by the University of Cambridge, England. It is
|
|
|
|
available at <ulink url="&url.pcre;">&url.pcre;</ulink>.
|
2002-04-15 00:12:54 +00:00
|
|
|
</para>
|
|
|
|
</section>
|
2002-12-01 17:10:18 +00:00
|
|
|
|
|
|
|
&reference.pcre.configure;
|
2002-04-15 00:12:54 +00:00
|
|
|
|
|
|
|
<section id="pcre.configuration">
|
2002-07-28 14:33:12 +00:00
|
|
|
&reftitle.runtime;
|
|
|
|
&no.config;
|
2002-04-15 00:12:54 +00:00
|
|
|
</section>
|
|
|
|
|
|
|
|
<section id="pcre.resources">
|
2002-07-28 14:33:12 +00:00
|
|
|
&reftitle.resources;
|
|
|
|
&no.resource;
|
2002-04-15 00:12:54 +00:00
|
|
|
</section>
|
|
|
|
|
2002-07-28 14:33:12 +00:00
|
|
|
&reference.pcre.constants;
|
2002-04-15 00:12:54 +00:00
|
|
|
|
|
|
|
<section id="pcre.examples">
|
2002-07-28 14:33:12 +00:00
|
|
|
&reftitle.examples;
|
2002-04-15 00:12:54 +00:00
|
|
|
<para>
|
|
|
|
<example>
|
2003-10-22 19:52:45 +00:00
|
|
|
<title>Examples of valid patterns</title>
|
2002-04-15 00:12:54 +00:00
|
|
|
<itemizedlist>
|
2002-06-13 07:55:02 +00:00
|
|
|
<listitem><simpara><literal>/<\/\w+>/</literal></simpara></listitem>
|
|
|
|
<listitem><simpara><literal>|(\d{3})-\d+|Sm</literal></simpara></listitem>
|
|
|
|
<listitem><simpara><literal>/^(?i)php[34]/</literal></simpara></listitem>
|
|
|
|
<listitem><simpara><literal>{^\s+(\s+)?$}</literal></simpara></listitem>
|
2002-04-15 00:12:54 +00:00
|
|
|
</itemizedlist>
|
|
|
|
</example>
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
<example>
|
2003-10-22 19:52:45 +00:00
|
|
|
<title>Examples of invalid patterns</title>
|
2002-04-15 00:12:54 +00:00
|
|
|
<itemizedlist>
|
|
|
|
<listitem>
|
|
|
|
<simpara>
|
2003-10-22 19:52:45 +00:00
|
|
|
<literal>/href='(.*)'</literal> - missing ending delimiter
|
2002-04-15 00:12:54 +00:00
|
|
|
</simpara>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<simpara>
|
2003-10-22 19:52:45 +00:00
|
|
|
<literal>/\w+\s*\w+/J</literal> - unknown modifier 'J'
|
2002-04-15 00:12:54 +00:00
|
|
|
</simpara>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<simpara>
|
2003-10-22 19:52:45 +00:00
|
|
|
<literal>1-\d3-\d3-\d4|</literal> - missing starting delimiter
|
2002-04-15 00:12:54 +00:00
|
|
|
</simpara>
|
|
|
|
</listitem>
|
|
|
|
</itemizedlist>
|
|
|
|
</example>
|
|
|
|
</para>
|
|
|
|
</section>
|
|
|
|
</partintro>
|
|
|
|
|
2004-03-03 05:06:14 +00:00
|
|
|
&reference.pcre.pattern.modifiers;
|
|
|
|
&reference.pcre.pattern.syntax;
|
2002-04-15 00:12:54 +00:00
|
|
|
&reference.pcre.functions;
|
|
|
|
|
|
|
|
</reference>
|
|
|
|
|
|
|
|
<!-- 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
|
|
|
|
-->
|
2003-10-22 19:52:45 +00:00
|
|
|
|