Regular expression Format _php tutorial

Source: Internet
Author: User
Tags ereg posix
Regular expressions are used in PHP to handle complex strings of text. The functions that support regular expressions are:
Ereg ()
Ereg replace ()
Eregi replace ()
Split ()
Each of these functions takes a regular expression as their first argument. PHP uses POSIX extension rule expressions (using POSIX 1003.2). To find all descriptions of POSIX extension rule expressions, see the Regex man page included in the PHP release.
Example 2-4. Regular expression Examples
Ereg ("abc", $string);
/* 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. */
Eregi ("(ozilla.[ 23]| MSIE.3) ", $HTTP _user_agent);
/* Returns true if client browser
Is Netscape 2, 3 or MSIE 3. */
Ereg ("([[: alnum:]]+)" ([: alnum:]]+) ([alnum:]]+)],
$string, $regs);
/* Places three space separated words
into $regs [1], $regs [2] and $regs [3]. */

Ereg_replace ("^", "
", $string);
/* Put A
Tag at the beginning of $string. */
Ereg_replace ("$", "
", $string);
/* Put A
Tag at the end of $string. */
Ereg_replace ("", "", $string);
/* Get rid of any carriage return
Characters in $string. */

http://www.bkjia.com/PHPjc/531925.html www.bkjia.com true http://www.bkjia.com/PHPjc/531925.html techarticle regular expressions are used in PHP to handle complex strings of text. The functions that support regular expressions are: Ereg () ereg replace () eregi replace () split () These functions all use regular expressions as ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.