Sophie

Sophie

distrib > Mandriva > 9.1 > ppc > media > main > by-pkgid > 0afeee9cca140e167a996902b9a677c5 > files > 3125

php-manual-en-4.3.0-2mdk.noarch.rpm

<HTML
><HEAD
><TITLE
>Regular Expression Functions (Perl-Compatible)</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="PHP Manual"
HREF="index.html"><LINK
REL="UP"
TITLE="Function Reference"
HREF="funcref.html"><LINK
REL="PREVIOUS"
TITLE="recode"
HREF="function.recode.html"><LINK
REL="NEXT"
TITLE="Pattern Modifiers"
HREF="pcre.pattern.modifiers.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=ISO-8859-1"></HEAD
><BODY
CLASS="reference"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation 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.recode.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="pcre.pattern.modifiers.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="reference"
><A
NAME="ref.pcre"
></A
><DIV
CLASS="TITLEPAGE"
><H1
CLASS="title"
>LXXXVIII. Regular Expression Functions (Perl-Compatible)</H1
><DIV
CLASS="PARTINTRO"
><A
NAME="AEN80841"
></A
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="pcre.intro"
></A
>Introduction</H1
><P
>&#13;     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 &#60;&#62; matching delimiters.
    </P
><P
>&#13;     The ending delimiter may be followed by various modifiers that
     affect the matching. 
     See <A
HREF="pcre.pattern.modifiers.html"
>Pattern Modifiers</A
>.
    </P
><P
>&#13;     PHP also supports regular expressions using a POSIX-extended syntax
     using the <A
HREF="ref.regex.html"
>POSIX-extended regex functions.</A
>.
    </P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="pcre.requirements"
></A
>Requirements</H1
><P
>&#13;     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 <A
HREF="ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/"
TARGET="_top"
>ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/</A
>.
    </P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="pcre.installation"
></A
>Installation</H1
><P
>&#13;  Beginning with PHP 4.2.0 these functions are enabled by default. You can
  disable the pcre functions with
  <TT
CLASS="option"
>--without-pcre-regex</TT
>. Use
  <TT
CLASS="option"
> --with-pcre-regex=DIR</TT
> to specify DIR
  where PCRE's include and library files are located, if not using bundled library.
  For older versions you have to configure and compile PHP 
  with <TT
CLASS="option"
>--with-pcre-regex[=DIR]</TT
> in order
  to use these functions.
 </P
><P
> The windows version of <TT
CLASS="literal"
>PHP</TT
>
has built in support for this extension. You do not need to load any additional
extension in order to use these functions.</P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="pcre.configuration"
></A
>Runtime Configuration</H1
><P
>This extension has no configuration directives defined in <TT
CLASS="filename"
>php.ini</TT
>.</P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="pcre.resources"
></A
>Resource Types</H1
><P
>This extension has no resource types defined.</P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="pcre.constants"
></A
>Predefined Constants</H1
><P
>&#13;The constants below are defined by this extension, and
will only be available when the extension has either
been compiled into PHP or dynamically loaded at runtime.
</P
><DIV
CLASS="table"
><A
NAME="AEN80871"
></A
><P
><B
>Table 1. PREG constants</B
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><THEAD
><TR
><TH
ALIGN="LEFT"
VALIGN="MIDDLE"
>constant</TH
><TH
ALIGN="LEFT"
VALIGN="MIDDLE"
>description</TH
></TR
></THEAD
><TBODY
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>PREG_PATTERN_ORDER</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>&#13;      Orders results so that $matches[0] is an array of full pattern
      matches, $matches[1] is an array of strings matched by the first
      parenthesized subpattern, and so on. This flag is only used with
      <A
HREF="function.preg-match-all.html"
><B
CLASS="function"
>preg_match_all()</B
></A
>.
     </TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>PREG_SET_ORDER</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>&#13;      Orders results so that $matches[0] is an array of first set of
      matches, $matches[1] is an array of second set of matches, and so
      on. This flag is only used with <A
HREF="function.preg-match-all.html"
><B
CLASS="function"
>preg_match_all()</B
></A
>.
     </TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>PREG_OFFSET_CAPTURE</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>&#13;      See the description of
      <TT
CLASS="constant"
><B
>PREG_SPLIT_OFFSET_CAPTURE</B
></TT
>.  This flag is
      available since <TT
CLASS="literal"
>PHP</TT
> 4.3.0 .
     </TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>PREG_SPLIT_NO_EMPTY</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>&#13;      This flag tells <A
HREF="function.preg-split.html"
><B
CLASS="function"
>preg_split()</B
></A
> to only return only
      non-empty pieces.
     </TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>PREG_SPLIT_DELIM_CAPTURE</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>&#13;      This flag tells <A
HREF="function.preg-split.html"
><B
CLASS="function"
>preg_split()</B
></A
> to capture
      parenthesized expression in the delimiter pattern as well. This flag
      is available since <TT
CLASS="literal"
>PHP</TT
> 4.0.5 .
     </TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>PREG_SPLIT_OFFSET_CAPTURE</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>&#13;      If this flag is set, for every occuring match the appendant string
      offset will also be returned. Note that this changes the return
      value in an array where very element is an array consisting of the
      matched string at offset 0 and it's string offset into subject at
      offset 1. This flag is available since <TT
CLASS="literal"
>PHP</TT
> 4.3.0
      and is only used for <A
HREF="function.preg-split.html"
><B
CLASS="function"
>preg_split()</B
></A
>.
     </TD
></TR
></TBODY
></TABLE
></DIV
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="pcre.examples"
></A
>Examples</H1
><P
>&#13;     <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN80909"
></A
><P
><B
>Example 1. Examples of valid patterns</B
></P
><P
></P
><UL
><LI
><P
><TT
CLASS="literal"
>/&#60;\/\w+&#62;/</TT
></P
></LI
><LI
><P
><TT
CLASS="literal"
>|(\d{3})-\d+|Sm</TT
></P
></LI
><LI
><P
><TT
CLASS="literal"
>/^(?i)php[34]/</TT
></P
></LI
><LI
><P
><TT
CLASS="literal"
>{^\s+(\s+)?$}</TT
></P
></LI
></UL
></DIV
></TD
></TR
></TABLE
>
    </P
><P
>&#13;     <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN80925"
></A
><P
><B
>Example 2. Examples of invalid patterns</B
></P
><P
></P
><UL
><LI
><P
>&#13;         <TT
CLASS="literal"
>/href='(.*)'</TT
> - missing ending delimiter
        </P
></LI
><LI
><P
>&#13;         <TT
CLASS="literal"
>/\w+\s*\w+/J</TT
> - unknown modifier 'J'
        </P
></LI
><LI
><P
>&#13;         <TT
CLASS="literal"
>1-\d3-\d3-\d4|</TT
> - missing starting delimiter
        </P
></LI
></UL
></DIV
></TD
></TR
></TABLE
>
    </P
></DIV
></DIV
><DIV
CLASS="TOC"
><DL
><DT
><B
>Table of Contents</B
></DT
><DT
><A
HREF="pcre.pattern.modifiers.html"
>Pattern Modifiers</A
>&nbsp;--&nbsp;Describes possible modifiers in regex
     patterns</DT
><DT
><A
HREF="pcre.pattern.syntax.html"
>Pattern Syntax</A
>&nbsp;--&nbsp;Describes PCRE regex syntax</DT
><DT
><A
HREF="function.preg-grep.html"
>preg_grep</A
>&nbsp;--&nbsp;
     Return array entries that match the pattern
    </DT
><DT
><A
HREF="function.preg-match-all.html"
>preg_match_all</A
>&nbsp;--&nbsp;Perform a global regular expression match</DT
><DT
><A
HREF="function.preg-match.html"
>preg_match</A
>&nbsp;--&nbsp;Perform a regular expression match</DT
><DT
><A
HREF="function.preg-quote.html"
>preg_quote</A
>&nbsp;--&nbsp;Quote regular expression characters</DT
><DT
><A
HREF="function.preg-replace-callback.html"
>preg_replace_callback</A
>&nbsp;--&nbsp;Perform a regular expression search and replace using a callback</DT
><DT
><A
HREF="function.preg-replace.html"
>preg_replace</A
>&nbsp;--&nbsp;Perform a regular expression search and replace</DT
><DT
><A
HREF="function.preg-split.html"
>preg_split</A
>&nbsp;--&nbsp;Split string by a regular expression</DT
></DL
></DIV
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="function.recode.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="pcre.pattern.modifiers.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>recode</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="funcref.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Pattern Modifiers</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>