Perl正则表达式在PHP的实现达成,我们要使用PCRE相关的正则表达式函数,那么具体的都有什么函数呢?这里我们向你介绍4个,希望对你有所帮助。
Perl正则表达式在PHP的实现所使用的函数介绍:
1、preg_match :
函数格式:
<ol class="dp-c"><li class="alt"><span><span>int preg_match(string pattern, string subject, </span><span class="keyword">array</span><span> [matches]); </span></span></li></ol>
这个函数会在string中使用pattern表达式来匹配,如果给定了[regs],就会将string记录到[regs][0]中,[regs][1]代表使用括号"()"记录下来的第一个字符串,[regs][2]代表记录下来的第二个字符串,以此类推。preg如果在string中找到了匹配的pattern,就会返回"true",否则返回"false"。
2、preg_replace :
函数格式:
<ol class="dp-c"><li class="alt"><span><span>mixed preg_replace(mixed pattern, mixed replacement, mixed subject); </span></span></li></ol>
这个函数会使用将string中符合表达式pattern的字符串全部替换为表达式replacement。如果replacement中需要包含pattern的部分字符,则可以使用"()"来记录,在replacement中只是需要用"

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver CS6
Visual web development tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Zend Studio 13.0.1
Powerful PHP integrated development environment

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool