Regular Expression Function_PHP Tutorial

WBOY
Release: 2016-07-20 10:59:50
Original
737 people have browsed it

​ PHP is similar to other cross-platform languages ​​(maybe Java is not one of them. :)), and it also has regular expression functions. Of course, the regular expression function of PHP3.0 is far inferior to Perl, but it is still useful enough. The main functions are as follows Some:
(1) ereg, eregi
This is a regular expression matching function. The former is case-related matching, while the latter is irrelevant.
Usage: ereg(regular expression, string, [match part of array name]);
The regular expressions in PHP3.0 are roughly similar to those used in grep.

(2)ereg_replace,eregi_replace
These are replacement functions.
Usage:
ereg_replace(regular expression, replacement string, original string);
There is a strtr in the string processing function, which is a "translation" function, similar to tr/.../.../,
in Perl Usage: strtr(string,"from","to");
For example: strtr("aaabb","ab","cd") returns "cccdd".

(3)split
It is similar to the explode function, but this time you can split the string where it matches a regular expression.
Usage:
split(regular expression, string, [remove the first number of items]);

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445572.htmlTechArticlePHP is similar to other cross-platform languages ​​(maybe Java is not one of them. :)) and also has regular expression functions. Of course, the regular expression function of PHP3.0 is far inferior to that of Perl, but it is still useful enough. The main functions are...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!