Analysis of PHP regular expression function library _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
Tags ereg php windows
Analyze the PHP regular expression function library. What is the PHP regular expression function library? Here we will introduce you to the PHP regular expression function library (POSIX extension) greedy Matching. we should note that what is the condition submode and many other analysis PHP regular expression function library? Here we will introduce you to the PHP regular expression function library (POSIX extension) greedy matching, unsupported features in the condition submode and many other POSIX Extended Regular expression syntaxes.

Warning in PHP regular expression function library learning:

This type of regular expression cannot be safely used in binary mode. You can use the PCRE function library. Regular expressions are used in PHP for complex string operations. Functions that support regular expressions are:

◆ Ereg ()

◆ Ereg_replace ()

◆ Eregi ()

◆ Eregi_replace ()

◆ Split ()

◆ Spliti ()

These functions all accept a regular expression string as its first parameter. PHP uses the POSIX extension regular expression defined by POSIX 1003.3. For a complete description of POSIX regular expressions, see the man page in the regex Directory of the PHP release package. You can use commands similar to man/usr/local/src/regex/regex.7.

Requirement: you can add external library files to the support of this extension module.

Installation warning: do not change the TYPE unless you know what you are doing.

To activate regexp support, add -- with-regex [= TYPE] when configuring PHP. TYPE can be system, apache, or php. Php is used by default.

PHP Windows has built-in support for this extension module. You can use these functions without loading any additional extension libraries. Let's take a look at the specific operations:

◆ Runtime configuration: no setting commands are defined for this extension module.

◆ Resource type: this extension module does not define any resource type.

◆ Predefined constant: this extension module does not define any constants.

Example of a PHP regular expression function:

 
 
  1. // If "abc" is found anywhere in $ string, & true;
  2. Ereg("Abc",$ String);
  3. // If $ string starts with "abc", & true;
  4. Ereg("^ Abc",$ String);
  5. // If $ string ends with "abc", return & true;
  6. Ereg("Abc $",$ String);
  7. // If your browser is Netscape 2, 3 or MSIE 3, & true;
  8. Eregi("(Ozilla. [23] | MSIE.3 )",$ HTTP_USER_AGENT);
  9. // Put words separated by three spaces in $ regs [1], $ regs [2], and $ regs [3]
  10. Ereg("([[: Alnum:] +) ([[: alnum:] +)
  11. ([[: Alnum:] + )",$ String,$ Regs);
  12. // Set
    Mark it at the beginning of $ string
  13. $ String=Ereg_replace("^","
    ",$ String);
  14. // Set
    Mark to end with $ string
  15. $ String=Ereg_replace("$","
    ",$ String);
  16. // Delete all linefeeds in $ string
  17. $ String=Ereg_replace("N","",$ String);
  18. ?>

The introduction of PHP regular expression functions will introduce you here. I hope you can understand and learn PHP regular expression functions.


Why? Here we will introduce you to the PHP regular expression function library (POSIX extension) greedy Matching. we should note that in the condition submode and many other...

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.