Regular Expression Function_PHP Tutorial
Jul 20, 2016 am 10:59 AM
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]);

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian

How To Set Up Visual Studio Code (VS Code) for PHP Development

How do you parse and process HTML/XML in PHP?

Break or return from Java 8 stream forEach?

PHP Program to Count Vowels in a String

Java Made Simple: A Beginner's Guide to Programming Power

Create the Future: Java Programming for Absolute Beginners

Java Program to Find the Volume of Capsule
