<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML ><HEAD ><TITLE >Regular Expression Functions (POSIX Extended)</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="Manual PHP" HREF="index.html"><LINK REL="UP" TITLE="Documentaþia funcþiilor" HREF="funcref.html"><LINK REL="PREVIOUS" TITLE="qdom_tree" HREF="function.qdom-tree.html"><LINK REL="NEXT" TITLE="ereg_replace" HREF="function.ereg-replace.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-2"></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" >Manual PHP</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.qdom-tree.html" ACCESSKEY="P" >Înapoi</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.ereg-replace.html" ACCESSKEY="N" >Înainte</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="reference" ><A NAME="ref.regex" ></A ><DIV CLASS="TITLEPAGE" ><H1 CLASS="title" >XCVI. Regular Expression Functions (POSIX Extended)</H1 ><DIV CLASS="PARTINTRO" ><A NAME="AEN100436" ></A ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="regex.intro" >Introducere</A ></H1 ><DIV CLASS="tip" ><BLOCKQUOTE CLASS="tip" ><P ><B >Indicaþie: </B > PHP also supports regular expressions using a Perl-compatible syntax using the <A HREF="ref.pcre.html" >PCRE functions</A >. Those functions support non-greedy matching, assertions, conditional subpatterns, and a number of other features not supported by the POSIX-extended regular expression syntax. </P ></BLOCKQUOTE ></DIV ><DIV CLASS="warning" ><P ></P ><TABLE CLASS="warning" BORDER="1" WIDTH="100%" ><TR ><TD ALIGN="CENTER" ><B >Avertisment</B ></TD ></TR ><TR ><TD ALIGN="LEFT" ><P > These regular expression functions are not binary-safe. The <A HREF="ref.pcre.html" >PCRE functions</A > are. </P ></TD ></TR ></TABLE ></DIV ><P > Regular expressions are used for complex string manipulation. PHP uses the POSIX extended regular expressions as defined by POSIX 1003.2. For a full description of POSIX regular expressions see the regex man pages included in the regex directory in the PHP distribution. It's in manpage format, so you'll want to do something along the lines of <B CLASS="command" >man /usr/local/src/regex/regex.7</B > in order to read it. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="regex.requirements" >Necesitãþi</A ></H1 ><P >Aceste funcþii sunt disponibile ca pãrþi ale modulului standard care este întotdeauna disponibil.</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="regex.installation" >Instalare</A ></H1 ><DIV CLASS="warning" ><P ></P ><TABLE CLASS="warning" BORDER="1" WIDTH="100%" ><TR ><TD ALIGN="CENTER" ><B >Avertisment</B ></TD ></TR ><TR ><TD ALIGN="LEFT" ><P > Do not change the TYPE unless you know what you are doing. </P ></TD ></TR ></TABLE ></DIV ><P > To enable regexp support configure PHP <VAR CLASS="option" >--with-regex[=TYPE]</VAR >. TYPE can be one of system, apache, php. The default is to use php. </P ><P > The windows version of <VAR CLASS="literal" >PHP</VAR > 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="regex.configuration" >Configurare la rulare</A ></H1 ><P >Aceastã extensie nu defineºte directive de configurare.</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="regex.resources" >Tipuri de resurse</A ></H1 ><P >Aceastã extensie nu defineºte tipuri de resurse.</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="regex.constants" >Constante predefinite</A ></H1 ><P >Aceastã extensie nu defineºte constante.</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="regex.examples" >Exemple</A ></H1 ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN100470" ></A ><P ><B >Exemplu 1. Regular Expression Examples</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><code><font color="#000000"> <font color="#0000BB"><?php<br /></font><font color="#FF8000">// Returns true if "abc" is found anywhere in $string.<br /></font><font color="#0000BB">ereg</font><font color="#007700">(</font><font color="#DD0000">"abc"</font><font color="#007700">, </font><font color="#0000BB">$string</font><font color="#007700">); <br /><br /></font><font color="#FF8000">// Returns true if "abc" is found at the beginning of $string.<br /></font><font color="#0000BB">ereg</font><font color="#007700">(</font><font color="#DD0000">"^abc"</font><font color="#007700">, </font><font color="#0000BB">$string</font><font color="#007700">);<br /><br /></font><font color="#FF8000">// Returns true if "abc" is found at the end of $string.<br /></font><font color="#0000BB">ereg</font><font color="#007700">(</font><font color="#DD0000">"abc</font><font color="#007700">$</font><font color="#DD0000">"</font><font color="#007700">, </font><font color="#0000BB">$string</font><font color="#007700">);<br /><br /></font><font color="#FF8000">// Returns true if client browser is Netscape 2, 3 or MSIE 3.<br /></font><font color="#0000BB">eregi</font><font color="#007700">(</font><font color="#DD0000">"(ozilla.[23]|MSIE.3)"</font><font color="#007700">, </font><font color="#0000BB">$HTTP_USER_AGENT</font><font color="#007700">); <br /><br /></font><font color="#FF8000">// Places three space separated words into $regs[1], $regs[2] and $regs[3].<br /></font><font color="#0000BB">ereg</font><font color="#007700">(</font><font color="#DD0000">"([[:alnum:]]+) ([[:alnum:]]+) ([[:alnum:]]+)"</font><font color="#007700">, </font><font color="#0000BB">$string</font><font color="#007700">, </font><font color="#0000BB">$regs</font><font color="#007700">); <br /><br /></font><font color="#FF8000">// Put a <br /> tag at the beginning of $string.<br /></font><font color="#0000BB">$string </font><font color="#007700">= </font><font color="#0000BB">ereg_replace</font><font color="#007700">(</font><font color="#DD0000">"^"</font><font color="#007700">, </font><font color="#DD0000">"<br />"</font><font color="#007700">, </font><font color="#0000BB">$string</font><font color="#007700">); <br /> <br /></font><font color="#FF8000">// Put a <br /> tag at the end of $string.<br /></font><font color="#0000BB">$string </font><font color="#007700">= </font><font color="#0000BB">ereg_replace</font><font color="#007700">(</font><font color="#DD0000">"</font><font color="#007700">$</font><font color="#DD0000">"</font><font color="#007700">, </font><font color="#DD0000">"<br />"</font><font color="#007700">, </font><font color="#0000BB">$string</font><font color="#007700">); <br /><br /></font><font color="#FF8000">// Get rid of any newline characters in $string.<br /></font><font color="#0000BB">$string </font><font color="#007700">= </font><font color="#0000BB">ereg_replace</font><font color="#007700">(</font><font color="#DD0000">"\n"</font><font color="#007700">, </font><font color="#DD0000">""</font><font color="#007700">, </font><font color="#0000BB">$string</font><font color="#007700">);<br /></font><font color="#0000BB">?></font> </font> </code></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="regex.seealso" >Vezi, de asemenea,</A ></H1 ><P > For regular expressions in Perl-compatible syntax have a look at the <A HREF="ref.pcre.html" >PCRE functions</A >. The simpler shell style wildcard pattern matching is provided by <A HREF="function.fnmatch.html" ><B CLASS="function" >fnmatch()</B ></A >. </P ></DIV ></DIV ><DIV CLASS="TOC" ><DL ><DT ><B >Cuprins</B ></DT ><DT ><A HREF="function.ereg-replace.html" >ereg_replace</A > -- Replace regular expression</DT ><DT ><A HREF="function.ereg.html" >ereg</A > -- Regular expression match</DT ><DT ><A HREF="function.eregi-replace.html" >eregi_replace</A > -- replace regular expression case insensitive</DT ><DT ><A HREF="function.eregi.html" >eregi</A > -- case insensitive regular expression match</DT ><DT ><A HREF="function.split.html" >split</A > -- split string into array by regular expression</DT ><DT ><A HREF="function.spliti.html" >spliti</A > -- Split string into array by regular expression case insensitive </DT ><DT ><A HREF="function.sql-regcase.html" >sql_regcase</A > -- Make regular expression for case insensitive match </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.qdom-tree.html" ACCESSKEY="P" >Înapoi</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Acasã</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.ereg-replace.html" ACCESSKEY="N" >Înainte</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >qdom_tree</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="funcref.html" ACCESSKEY="U" >Sus</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >ereg_replace</TD ></TR ></TABLE ></DIV ></BODY ></HTML >