Home Backend Development PHP Tutorial Regular Expression Function_PHP Tutorial

Regular Expression Function_PHP Tutorial

Jul 20, 2016 am 10:59 AM
java php and function Function regular expression language Cross-platform

​ 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...
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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

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

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

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

Break or return from Java 8 stream forEach? Break or return from Java 8 stream forEach? Feb 07, 2025 pm 12:09 PM

Break or return from Java 8 stream forEach?

PHP Program to Count Vowels in a String PHP Program to Count Vowels in a String Feb 07, 2025 pm 12:12 PM

PHP Program to Count Vowels in a String

Java Made Simple: A Beginner's Guide to Programming Power Java Made Simple: A Beginner's Guide to Programming Power Oct 11, 2024 pm 06:30 PM

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

Create the Future: Java Programming for Absolute Beginners Create the Future: Java Programming for Absolute Beginners Oct 13, 2024 pm 01:32 PM

Create the Future: Java Programming for Absolute Beginners

Java Program to Find the Volume of Capsule Java Program to Find the Volume of Capsule Feb 07, 2025 am 11:37 AM

Java Program to Find the Volume of Capsule

See all articles