php-doc-en/reference/regex/examples.xml
Philip Olson 751d5e9a41 MFB: Upgrade to the new-reference-structure
- Split reference.xml into book.xml, setup.xml, constants.xml, and examples.xml
- Moved from reference.xml to book.xml:
  - The intro text (partintro), and link to various pages
- Moved from reference.xml to setup.xml:
  - The rest: requirements, installation, configuration, and resources
- Moved constants from reference.xml to new constants.xml
- Moved examples from reference.xml to new examples.xml
- Changed the intro ID from <extname>.intro to intro.<extname>


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@248706 c90b9560-bf6c-de11-be94-00142212c4b1
2007-12-21 23:53:46 +00:00

62 lines
1.5 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.2 $ -->
<appendix xml:id="regex.examples">
&reftitle.examples;
<para>
<example>
<title>Regular Expression Examples</title>
<programlisting role="php">
<![CDATA[
<?php
// Returns true if "abc" is found anywhere in $string.
ereg("abc", $string);
// Returns true if "abc" is found at the beginning of $string.
ereg("^abc", $string);
// Returns true if "abc" is found at the end of $string.
ereg("abc$", $string);
// Returns true if client browser is Netscape 2, 3 or MSIE 3.
eregi("(ozilla.[23]|MSIE.3)", $_SERVER["HTTP_USER_AGENT"]);
// Places three space separated words into $regs[1], $regs[2] and $regs[3].
ereg("([[:alnum:]]+) ([[:alnum:]]+) ([[:alnum:]]+)", $string, $regs);
// Put a <br /> tag at the beginning of $string.
$string = ereg_replace("^", "<br />", $string);
// Put a <br /> tag at the end of $string.
$string = ereg_replace("$", "<br />", $string);
// Get rid of any newline characters in $string.
$string = ereg_replace("\n", "", $string);
?>
]]>
</programlisting>
</example>
</para>
</appendix>
<!-- 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
-->