Regular Expression Functions

Source: Internet
Author: User

PHP and other cross-platform languages (maybe Java is not listed in it. :)) Similarly, the regular expression function is also available. the Regular Expression Function of PHP3.0 is far inferior to Perl, but it is still enough. The main functions include:
(1) ereg, eregi
This is a regular expression matching function. The former is case-sensitive and the latter is irrelevant.
Usage: ereg (Regular Expression, String, [matching partial array names]);
The regular expressions in PHP3.0 are similar to those in grep.

(2) ereg_replace, eregi_replace
These are replacement functions.
Usage:
Ereg_replace (Regular Expression, replacement string, original string );
The string processing function has a strtr, which is a "Translation" function, similar to tr/.../in Perl /.../.../,
Usage: strtr (string, "from", "");
For example, strtr ("aaabb", "AB", "cd") returns "cccdd ".

(3) split
It is similar to the explode function, but this time it can be used to split the string where a regular expression is matched.
Usage:
Split (Regular Expression, String, [number of items before removal]);

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.