mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
ref.regex: new doc style
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@237709 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
f16f0a48ea
commit
d2493f8e3f
7 changed files with 546 additions and 162 deletions
|
@ -1,13 +1,13 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.7 $ -->
|
||||
<!-- splitted from ./en/functions/regex.xml, last change in rev 1.2 -->
|
||||
<!-- $Revision: 1.8 $ -->
|
||||
<refentry id="function.ereg-replace">
|
||||
<refnamediv>
|
||||
<refname>ereg_replace</refname>
|
||||
<refpurpose>Replace regular expression</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<type>string</type><methodname>ereg_replace</methodname>
|
||||
<methodparam><type>string</type><parameter>pattern</parameter></methodparam>
|
||||
|
@ -19,26 +19,56 @@
|
|||
<parameter>pattern</parameter>, then replaces the matched text
|
||||
with <parameter>replacement</parameter>.
|
||||
</simpara>
|
||||
<simpara>
|
||||
The modified string is returned. (Which may mean that the
|
||||
original string is returned if there are no matches to be
|
||||
replaced.)
|
||||
</simpara>
|
||||
<simpara>
|
||||
If <parameter>pattern</parameter> contains parenthesized
|
||||
substrings, <parameter>replacement</parameter> may contain
|
||||
substrings of the form
|
||||
<literal>\\<replaceable>digit</replaceable></literal>, which will
|
||||
be replaced by the text matching the digit'th parenthesized
|
||||
substring; <literal>\\0</literal> will produce the entire
|
||||
contents of string. Up to nine substrings may be used.
|
||||
Parentheses may be nested, in which case they are counted by the
|
||||
opening parenthesis.
|
||||
</simpara>
|
||||
<simpara>
|
||||
If no matches are found in <parameter>string</parameter>, then
|
||||
<parameter>string</parameter> will be returned unchanged.
|
||||
</simpara>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<para>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>pattern</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
A POSIX extended regular expression.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><parameter>replacement</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
If <parameter>pattern</parameter> contains parenthesized substrings,
|
||||
<parameter>replacement</parameter> may contain substrings of the form
|
||||
<literal>\\<replaceable>digit</replaceable></literal>, which will be
|
||||
replaced by the text matching the digit'th parenthesized substring;
|
||||
<literal>\\0</literal> will produce the entire contents of string.
|
||||
Up to nine substrings may be used. Parentheses may be nested, in which
|
||||
case they are counted by the opening parenthesis.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><parameter>string</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The input string.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
The modified string is returned. If no matches are found in
|
||||
<parameter>string</parameter>, then it will be returned unchanged.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
For example, the following code snippet prints "This was a test"
|
||||
three times:
|
||||
|
@ -102,6 +132,10 @@ $text = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]",
|
|||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="notes">
|
||||
&reftitle.notes;
|
||||
<tip>
|
||||
<para>
|
||||
<function>preg_replace</function>, which uses a Perl-compatible
|
||||
|
@ -109,13 +143,23 @@ $text = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]",
|
|||
<function>ereg_replace</function>.
|
||||
</para>
|
||||
</tip>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="seealso">
|
||||
&reftitle.seealso;
|
||||
<para>
|
||||
See also <function>ereg</function>, <function>eregi</function>,
|
||||
<function>eregi_replace</function>, <function>str_replace</function>, and
|
||||
<function>preg_match</function>.
|
||||
<simplelist>
|
||||
<member><function>ereg</function></member>
|
||||
<member><function>eregi</function></member>
|
||||
<member><function>eregi_replace</function></member>
|
||||
<member><function>str_replace</function></member>
|
||||
<member><function>preg_match</function></member>
|
||||
</simplelist>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
|
|
|
@ -1,65 +1,89 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.13 $ -->
|
||||
<!-- splitted from ./en/functions/regex.xml, last change in rev 1.2 -->
|
||||
<!-- $Revision: 1.14 $ -->
|
||||
<refentry id="function.ereg">
|
||||
<refnamediv>
|
||||
<refname>ereg</refname>
|
||||
<refpurpose>Regular expression match</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<type>int</type><methodname>ereg</methodname>
|
||||
<methodparam><type>string</type><parameter>pattern</parameter></methodparam>
|
||||
<methodparam><type>string</type><parameter>string</parameter></methodparam>
|
||||
<methodparam choice="opt"><type>array</type><parameter role="reference">regs</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<note>
|
||||
<para>
|
||||
<function>preg_match</function>, which uses a Perl-compatible
|
||||
regular expression syntax, is often a faster alternative to
|
||||
<function>ereg</function>.
|
||||
</para>
|
||||
</note>
|
||||
<simpara>
|
||||
Searches a <parameter>string</parameter> for matches to the regular
|
||||
expression given in <parameter>pattern</parameter> in a case-sensitive
|
||||
way.
|
||||
</simpara>
|
||||
<simpara>
|
||||
If matches are found for parenthesized substrings of
|
||||
<parameter>pattern</parameter> and the function is called with
|
||||
the third argument <parameter>regs</parameter>, the matches will
|
||||
be stored in the elements of the array
|
||||
<parameter>regs</parameter>. $regs[1] will contain the substring
|
||||
which starts at the first left parenthesis; $regs[2] will contain
|
||||
the substring starting at the second, and so on. $regs[0] will
|
||||
contain a copy of the complete string matched.
|
||||
</simpara>
|
||||
<note>
|
||||
<simpara>
|
||||
Up to (and including) PHP 4.1.0 <varname>$regs</varname> will be
|
||||
filled with exactly ten elements, even though more or fewer than
|
||||
ten parenthesized substrings may actually have matched. This has
|
||||
no effect on <function>ereg</function>'s ability to match more
|
||||
substrings. If no matches are found, <literal>$regs</literal>
|
||||
will not be altered by <function>ereg</function>.
|
||||
</simpara>
|
||||
</note>
|
||||
<simpara>
|
||||
Returns the length of the matched string if a match for <parameter>pattern</parameter> was
|
||||
found in <parameter>string</parameter>, or &false; if no matches
|
||||
were found or an error occurred.
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<para>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>pattern</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Case sensitive regular expression.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><parameter>string</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The input string.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><parameter>regs</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
If matches are found for parenthesized substrings of
|
||||
<parameter>pattern</parameter> and the function is called with the
|
||||
third argument <parameter>regs</parameter>, the matches will be stored
|
||||
in the elements of the array <parameter>regs</parameter>.
|
||||
</para>
|
||||
<para>
|
||||
$regs[1] will contain the substring which starts at the first left
|
||||
parenthesis; $regs[2] will contain the substring starting at the
|
||||
second, and so on. $regs[0] will contain a copy of the complete string
|
||||
matched.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
Returns the length of the matched string if a match for
|
||||
<parameter>pattern</parameter> was found in <parameter>string</parameter>,
|
||||
or &false; if no matches were found or an error occurred.
|
||||
</para>
|
||||
<para>
|
||||
If the optional parameter <parameter>regs</parameter> was not passed or
|
||||
the length of the matched string is 0, this function returns 1.
|
||||
</simpara>
|
||||
<para>
|
||||
The following code snippet takes a date in ISO format
|
||||
(YYYY-MM-DD) and prints it in DD.MM.YYYY format:
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
<example>
|
||||
<title><function>ereg</function> example</title>
|
||||
<para>
|
||||
The following code snippet takes a date in ISO format (YYYY-MM-DD) and
|
||||
prints it in DD.MM.YYYY format:
|
||||
</para>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
@ -73,13 +97,45 @@ if (ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", $date, $regs)) {
|
|||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="notes">
|
||||
&reftitle.notes;
|
||||
<note>
|
||||
<para>
|
||||
<function>preg_match</function>, which uses a Perl-compatible
|
||||
regular expression syntax, is often a faster alternative to
|
||||
<function>ereg</function>.
|
||||
</para>
|
||||
</note>
|
||||
<note>
|
||||
<simpara>
|
||||
Up to (and including) PHP 4.1.0 <varname>$regs</varname> will be
|
||||
filled with exactly ten elements, even though more or fewer than
|
||||
ten parenthesized substrings may actually have matched. This has
|
||||
no effect on <function>ereg</function>'s ability to match more
|
||||
substrings. If no matches are found, <literal>$regs</literal>
|
||||
will not be altered by <function>ereg</function>.
|
||||
</simpara>
|
||||
</note>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="seealso">
|
||||
&reftitle.seealso;
|
||||
<para>
|
||||
See also <function>eregi</function>, <function>ereg_replace</function>,
|
||||
<function>eregi_replace</function>, <function>preg_match</function>,
|
||||
<function>strpos</function>, and <function>strstr</function>.
|
||||
<simplelist>
|
||||
<member><function>eregi</function></member>
|
||||
<member><function>ereg_replace</function></member>
|
||||
<member><function>eregi_replace</function></member>
|
||||
<member><function>preg_match</function></member>
|
||||
<member><function>strpos</function></member>
|
||||
<member><function>strstr</function></member>
|
||||
</simplelist>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.7 $ -->
|
||||
<!-- splitted from ./en/functions/regex.xml, last change in rev 1.2 -->
|
||||
<!-- $Revision: 1.8 $ -->
|
||||
<refentry id="function.eregi-replace">
|
||||
<refnamediv>
|
||||
<refname>eregi_replace</refname>
|
||||
<refpurpose>Replace regular expression case insensitive</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<type>string</type><methodname>eregi_replace</methodname>
|
||||
<methodparam><type>string</type><parameter>pattern</parameter></methodparam>
|
||||
|
@ -19,6 +19,56 @@
|
|||
except that this ignores case distinction when matching
|
||||
alphabetic characters.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<para>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>pattern</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
A POSIX extended regular expression.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><parameter>replacement</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
If <parameter>pattern</parameter> contains parenthesized substrings,
|
||||
<parameter>replacement</parameter> may contain substrings of the form
|
||||
<literal>\\<replaceable>digit</replaceable></literal>, which will be
|
||||
replaced by the text matching the digit'th parenthesized substring;
|
||||
<literal>\\0</literal> will produce the entire contents of string.
|
||||
Up to nine substrings may be used. Parentheses may be nested, in which
|
||||
case they are counted by the opening parenthesis.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><parameter>string</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The input string.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
The modified string is returned. If no matches are found in
|
||||
<parameter>string</parameter>, then it will be returned unchanged.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
<example>
|
||||
<title>Highlight search results</title>
|
||||
|
@ -33,11 +83,19 @@ $body = eregi_replace($pattern, $replacement, $body);
|
|||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="seealso">
|
||||
&reftitle.seealso;
|
||||
<para>
|
||||
See also <function>ereg</function>, <function>eregi</function>,
|
||||
and <function>ereg_replace</function>.
|
||||
<simplelist>
|
||||
<member><function>ereg</function></member>
|
||||
<member><function>eregi</function></member>
|
||||
<member><function>ereg_replace</function></member>
|
||||
</simplelist>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
</refentry>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.10 $ -->
|
||||
<!-- splitted from ./en/functions/regex.xml, last change in rev 1.2 -->
|
||||
<!-- $Revision: 1.11 $ -->
|
||||
<refentry id="function.eregi">
|
||||
<refnamediv>
|
||||
<refname>eregi</refname>
|
||||
<refpurpose>Case insensitive regular expression match</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<type>int</type><methodname>eregi</methodname>
|
||||
<methodparam><type>string</type><parameter>pattern</parameter></methodparam>
|
||||
|
@ -15,10 +15,67 @@
|
|||
<methodparam choice="opt"><type>array</type><parameter role="reference">regs</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
This function is identical to <function>ereg</function> except
|
||||
that this ignores case distinction when matching alphabetic
|
||||
characters.
|
||||
This function is identical to <function>ereg</function> except that it
|
||||
ignores case distinction when matching alphabetic characters.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<para>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>pattern</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Case insensitive regular expression.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><parameter>string</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The input string.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><parameter>regs</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
If matches are found for parenthesized substrings of
|
||||
<parameter>pattern</parameter> and the function is called with the
|
||||
third argument <parameter>regs</parameter>, the matches will be stored
|
||||
in the elements of the array <parameter>regs</parameter>.
|
||||
</para>
|
||||
<para>
|
||||
$regs[1] will contain the substring which starts at the first left
|
||||
parenthesis; $regs[2] will contain the substring starting at the
|
||||
second, and so on. $regs[0] will contain a copy of the complete string
|
||||
matched.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
Returns the length of the matched string if a match for
|
||||
<parameter>pattern</parameter> was found in <parameter>string</parameter>,
|
||||
or &false; if no matches were found or an error occurred.
|
||||
</para>
|
||||
<para>
|
||||
If the optional parameter <parameter>regs</parameter> was not passed or
|
||||
the length of the matched string is 0, this function returns 1.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
<example>
|
||||
<title><function>eregi</function> example</title>
|
||||
|
@ -34,12 +91,21 @@ if (eregi('z', $string)) {
|
|||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="seealso">
|
||||
&reftitle.seealso;
|
||||
<para>
|
||||
See also <function>ereg</function>, <function>ereg_replace</function>,
|
||||
<function>eregi_replace</function>, <function>stripos</function>, and
|
||||
<function>stristr</function>.
|
||||
<simplelist>
|
||||
<member><function>ereg</function></member>
|
||||
<member><function>ereg_replace</function></member>
|
||||
<member><function>eregi_replace</function></member>
|
||||
<member><function>stripos</function></member>
|
||||
<member><function>stristr</function></member>
|
||||
</simplelist>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
</refentry>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
|
|
@ -1,45 +1,96 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.7 $ -->
|
||||
<!-- splitted from ./en/functions/regex.xml, last change in rev 1.7 -->
|
||||
<!-- $Revision: 1.8 $ -->
|
||||
<refentry id="function.split">
|
||||
<refnamediv>
|
||||
<refname>split</refname>
|
||||
<refpurpose>Split string into array by regular expression</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<type>array</type><methodname>split</methodname>
|
||||
<methodparam><type>string</type><parameter>pattern</parameter></methodparam>
|
||||
<methodparam><type>string</type><parameter>string</parameter></methodparam>
|
||||
<methodparam choice="opt"><type>int</type><parameter>limit</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<tip>
|
||||
<para>
|
||||
<function>preg_split</function>, which uses a Perl-compatible regular
|
||||
expression syntax, is often a faster alternative to
|
||||
<function>split</function>. If you don't require the power of regular
|
||||
expressions, it is faster to use <function>explode</function>, which
|
||||
doesn't incur the overhead of the regular expression engine.
|
||||
</para>
|
||||
</tip>
|
||||
<para>
|
||||
Splits a <parameter>string</parameter> into array by regular expression.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<para>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>pattern</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Case sensitive regular expression.
|
||||
</para>
|
||||
<para>
|
||||
If you want to split on any of the characters which are considered
|
||||
special by regular expressions, you'll need to escape them first. If
|
||||
you think <function>split</function> (or any other regex function, for
|
||||
that matter) is doing something weird, please read the file
|
||||
<filename>regex.7</filename>, included in the
|
||||
<filename>regex/</filename> subdirectory of the PHP distribution. It's
|
||||
in manpage format, so you'll want to do something along the lines of
|
||||
<command>man /usr/local/src/regex/regex.7</command> in order to read it.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><parameter>string</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The input string.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><parameter>limit</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
If <parameter>limit</parameter> is set, the returned array will
|
||||
contain a maximum of <parameter>limit</parameter> elements with the
|
||||
last element containing the whole rest of
|
||||
<parameter>string</parameter>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
Returns an array of strings, each of which is a substring of
|
||||
<parameter>string</parameter> formed by splitting it on
|
||||
boundaries formed by the case-sensitive regular expression
|
||||
<parameter>pattern</parameter>. If <parameter>limit</parameter>
|
||||
is set, the returned array will contain a maximum of
|
||||
<parameter>limit</parameter> elements with the last element
|
||||
containing the whole rest of <parameter>string</parameter>. If
|
||||
an error occurs, <function>split</function> returns &false;.
|
||||
<parameter>string</parameter> formed by splitting it on boundaries formed
|
||||
by the case-sensitive regular expression <parameter>pattern</parameter>.
|
||||
</para>
|
||||
<para>
|
||||
To split off the first four fields from a line from
|
||||
<filename>/etc/passwd</filename>:
|
||||
If there are <replaceable>n</replaceable> occurrences of
|
||||
<parameter>pattern</parameter>, the returned array will contain
|
||||
<literal><replaceable>n</replaceable>+1</literal> items. For example, if
|
||||
there is no occurrence of <parameter>pattern</parameter>, an array with
|
||||
only one element will be returned. Of course, this is also true if
|
||||
<parameter>string</parameter> is empty. If an error occurs,
|
||||
<function>split</function> returns &false;.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
<example>
|
||||
<title><function>split</function> example</title>
|
||||
<para>
|
||||
To split off the first four fields from a line from
|
||||
<filename>/etc/passwd</filename>:
|
||||
</para>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
@ -50,21 +101,12 @@ list($user, $pass, $uid, $gid, $extra) =
|
|||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<simpara>
|
||||
If there are <replaceable>n</replaceable> occurrences of
|
||||
<parameter>pattern</parameter>, the returned array will contain
|
||||
<literal><replaceable>n</replaceable>+1</literal> items. For example, if
|
||||
there is no occurrence of <parameter>pattern</parameter>, an array with
|
||||
only one element will be returned. Of course, this is also true if
|
||||
<parameter>string</parameter> is empty.
|
||||
</simpara>
|
||||
<para>
|
||||
To parse a date which may be delimited with slashes, dots, or
|
||||
hyphens:
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title><function>split</function> example</title>
|
||||
<para>
|
||||
To parse a date which may be delimited with slashes, dots, or hyphens:
|
||||
</para>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
@ -77,35 +119,45 @@ echo "Month: $month; Day: $day; Year: $year<br />\n";
|
|||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
For users looking for a way to emulate Perl's <command>@chars =
|
||||
split('', $str)</command> behaviour, please see the examples for
|
||||
<function>preg_split</function> or <function>str_split</function>.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Please note that <parameter>pattern</parameter> is a regular
|
||||
expression. If you want to split on any of the characters which
|
||||
are considered special by regular expressions, you'll need to
|
||||
escape them first. If you think <function>split</function> (or
|
||||
any other regex function, for that matter) is doing something
|
||||
weird, please read the file <filename>regex.7</filename>,
|
||||
included in the <filename>regex/</filename> subdirectory of the
|
||||
PHP distribution. It's in manpage format, so you'll want to do
|
||||
something along the lines of <command>man
|
||||
/usr/local/src/regex/regex.7</command> in order to read it.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
See also: <function>preg_split</function>, <function>spliti</function>,
|
||||
<function>str_split</function>,
|
||||
<function>explode</function>, <function>implode</function>,
|
||||
<function>chunk_split</function>, and <function>wordwrap</function>.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="notes">
|
||||
&reftitle.notes;
|
||||
<tip>
|
||||
<para>
|
||||
<function>preg_split</function>, which uses a Perl-compatible regular
|
||||
expression syntax, is often a faster alternative to
|
||||
<function>split</function>. If you don't require the power of regular
|
||||
expressions, it is faster to use <function>explode</function>, which
|
||||
doesn't incur the overhead of the regular expression engine.
|
||||
</para>
|
||||
</tip>
|
||||
<tip>
|
||||
<para>
|
||||
For users looking for a way to emulate Perl's <command>@chars =
|
||||
split('', $str)</command> behaviour, please see the examples for
|
||||
<function>preg_split</function> or <function>str_split</function>.
|
||||
</para>
|
||||
</tip>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="seealso">
|
||||
&reftitle.seealso;
|
||||
<para>
|
||||
<simplelist>
|
||||
<member><function>preg_split</function></member>
|
||||
<member><function>spliti</function></member>
|
||||
<member><function>str_split</function></member>
|
||||
<member><function>explode</function></member>
|
||||
<member><function>implode</function></member>
|
||||
<member><function>chunk_split</function></member>
|
||||
<member><function>wordwrap</function></member>
|
||||
</simplelist>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.7 $ -->
|
||||
<!-- splitted from ./en/functions/regex.xml, last change in rev 1.2 -->
|
||||
<!-- $Revision: 1.8 $ -->
|
||||
<refentry id="function.spliti">
|
||||
<refnamediv>
|
||||
<refname>spliti</refname>
|
||||
<refpurpose>Split string into array by regular expression case insensitive</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<type>array</type><methodname>spliti</methodname>
|
||||
<methodparam><type>string</type><parameter>pattern</parameter></methodparam>
|
||||
|
@ -15,10 +15,79 @@
|
|||
<methodparam choice="opt"><type>int</type><parameter>limit</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
This function is identical to <function>split</function> except
|
||||
that this ignores case distinction when matching alphabetic
|
||||
characters.
|
||||
Splits a <parameter>string</parameter> into array by regular expression.
|
||||
</para>
|
||||
<para>
|
||||
This function is identical to <function>split</function> except that this
|
||||
ignores case distinction when matching alphabetic characters.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<para>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>pattern</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Case insensitive regular expression.
|
||||
</para>
|
||||
<para>
|
||||
If you want to split on any of the characters which are considered
|
||||
special by regular expressions, you'll need to escape them first. If
|
||||
you think <function>split</function> (or any other regex function, for
|
||||
that matter) is doing something weird, please read the file
|
||||
<filename>regex.7</filename>, included in the
|
||||
<filename>regex/</filename> subdirectory of the PHP distribution. It's
|
||||
in manpage format, so you'll want to do something along the lines of
|
||||
<command>man /usr/local/src/regex/regex.7</command> in order to read it.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><parameter>string</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The input string.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><parameter>limit</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
If <parameter>limit</parameter> is set, the returned array will
|
||||
contain a maximum of <parameter>limit</parameter> elements with the
|
||||
last element containing the whole rest of
|
||||
<parameter>string</parameter>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
Returns an array of strings, each of which is a substring of
|
||||
<parameter>string</parameter> formed by splitting it on boundaries formed
|
||||
by the case-sensitive regular expression <parameter>pattern</parameter>.
|
||||
</para>
|
||||
<para>
|
||||
If there are <replaceable>n</replaceable> occurrences of
|
||||
<parameter>pattern</parameter>, the returned array will contain
|
||||
<literal><replaceable>n</replaceable>+1</literal> items. For example, if
|
||||
there is no occurrence of <parameter>pattern</parameter>, an array with
|
||||
only one element will be returned. Of course, this is also true if
|
||||
<parameter>string</parameter> is empty. If an error occurs,
|
||||
<function>split</function> returns &false;.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
This example splits a string using 'a' as the separator :
|
||||
<example>
|
||||
|
@ -47,12 +116,22 @@ Array
|
|||
</screen>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="seealso">
|
||||
&reftitle.seealso;
|
||||
<para>
|
||||
See also <function>preg_split</function>, <function>split</function>,
|
||||
<function>explode</function>, and <function>implode</function>.
|
||||
<simplelist>
|
||||
<member><function>preg_split</function></member>
|
||||
<member><function>split</function></member>
|
||||
<member><function>explode</function></member>
|
||||
<member><function>implode</function></member>
|
||||
</simplelist>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
|
|
|
@ -1,24 +1,51 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.7 $ -->
|
||||
<!-- splitted from ./en/functions/regex.xml, last change in rev 1.2 -->
|
||||
<!-- $Revision: 1.8 $ -->
|
||||
<refentry id="function.sql-regcase">
|
||||
<refnamediv>
|
||||
<refname>sql_regcase</refname>
|
||||
<refpurpose>Make regular expression for case insensitive match</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<type>string</type><methodname>sql_regcase</methodname>
|
||||
<methodparam><type>string</type><parameter>string</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Creates a regular expression for a case insensitive match.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<para>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>string</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The input string.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
Returns a valid regular expression which will match
|
||||
<parameter>string</parameter>, ignoring case. This expression is
|
||||
<parameter>string</parameter> with each alphabetic character converted to a
|
||||
bracket expression; this bracket expression contains that
|
||||
character's uppercase and lowercase form. Other characters remain unchanged.
|
||||
<parameter>string</parameter> with each alphabetic character converted to
|
||||
a bracket expression; this bracket expression contains that character's
|
||||
uppercase and lowercase form. Other characters remain unchanged.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
<example>
|
||||
<title><function>sql_regcase</function> example</title>
|
||||
|
@ -42,7 +69,9 @@ echo sql_regcase("Foo - bar.");
|
|||
products which support only case sensitive regular expressions.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
|
|
Loading…
Reference in a new issue