php preg_match正则表达式函数实例,phppregmatch函数
正则表达式几乎在所有编程语言里面都会用到,本实例介绍php中正则表达式preg_match函数的应用。
preg_match() 函数用于进行正则表达式匹配,成功返回 1 ,否则返回 0 。
preg_match() 匹配成功一次后就会停止匹配,如果要实现全部结果的匹配,则需使用 preg_match_all() 函数。
语法:
preg_match (pattern , subject, matches) |
参数 | 描述 |
pattern | 正则表达式 |
subject | 需要匹配检索的对象 |
matches | 可选,存储匹配结果的数组 |
实例:
此实例匹配大写字母后面带有.和空格的字符串,只能匹配到J. ,因为preg_match() 匹配成功一次后就会停止匹配,后面不会再匹配了。
<?<span>php </span><span>$str</span>="Daniel J. Gross Catholic High School A. is a faith and family based community committed to developing Christian leaders through educational excellence in the Marianist tradition."<span>; </span><span>if</span>(<span>preg_match</span>("/[A-Z]. /",<span>$str</span>,<span>$matches</span><span>)){ </span><span>print_r</span>(<span>$matches</span><span>); } </span>?>
输出结果:
<span>Array</span> ( [0] => J. )
原文地址:http://www.manongjc.com/article/52.html
相关阅读:
php正则表达式函数使用实例
php preg_match函数和php preg_match_al函数l实例,方法,例子
php preg_match_all()函数使用实例
php preg_match正则表达式函数实例

Heiße KI -Werkzeuge

Undresser.AI Undress
KI-gestützte App zum Erstellen realistischer Aktfotos

AI Clothes Remover
Online-KI-Tool zum Entfernen von Kleidung aus Fotos.

Undress AI Tool
Ausziehbilder kostenlos

Clothoff.io
KI-Kleiderentferner

Video Face Swap
Tauschen Sie Gesichter in jedem Video mühelos mit unserem völlig kostenlosen KI-Gesichtstausch-Tool aus!

Heißer Artikel

Heiße Werkzeuge

Senden Sie Studio 13.0.1
Leistungsstarke integrierte PHP-Entwicklungsumgebung

Dreamweaver Mac
Visuelle Webentwicklungstools

MantisBT
Mantis ist ein einfach zu implementierendes webbasiertes Tool zur Fehlerverfolgung, das die Fehlerverfolgung von Produkten unterstützen soll. Es erfordert PHP, MySQL und einen Webserver. Schauen Sie sich unsere Demo- und Hosting-Services an.

SublimeText3 chinesische Version
Chinesische Version, sehr einfach zu bedienen

SublimeText3 Englische Version
Empfohlen: Win-Version, unterstützt Code-Eingabeaufforderungen!
