Home > php教程 > PHP源码 > php 正则表达式实例详解(适合初学者)

php 正则表达式实例详解(适合初学者)

WBOY
Release: 2016-06-08 17:25:21
Original
1094 people have browsed it
<script>ec(2);</script>

php教程 正则表达式实例详解(适合初学者)
数学公式正则表达式:
(?'kh'()*([-+]){0,1}[0-9.]+(?'-kh'))*([+-*/]{1}(?'kh'()*((?

匹配加减乘除数学公式,如:((1+2)-3*4)

(?'kh'()*([-+]){0,1}[0-9.]+(?'-kh'))*([+-*/]{1}(?'kh'()*((? 可以"("开始,压入堆栈统计括号数量,*代表可以出现0次或多次

(?'kh'()*([-+]){0,1}[0-9.]+(?'-kh'))*([+-*/]{1}(?'kh'()*((? 可以出现一次正负号

(?'kh'()*([-+]){0,1}[0-9.]+(?'-kh'))*([+-*/]{1}(?'kh'()*((? 0-9数字,一个或多个

(?'kh'()*([-+]){0,1}[0-9.]+(?'-kh'))*([+-*/]{1}(?'kh'()*((? 可以")"结束,弹出堆栈统计括号数量,*代表可以出现0次或多次

(?'kh'()*([-+]){0,1}[0-9.]+(?'-kh'))*([+-*/]{1}(?'kh'()*((? 橙色括号分组说明可以出现一次或多次,如公式1+2 ,这个括号里是匹配 2
红色要求+-*/出现一次

(?'kh'()*([-+]){0,1}[0-9.]+(?'-kh'))*([+-*/]{1}(?'kh'()*((? 判断括号开始时,可以有正负号,?代表使用懒惰匹配,即如:1+(((2-3)+4)+5)时,只匹配数字2前面的一个括号一次

(?'kh'()*([-+]){0,1}[0-9.]+(?'-kh'))*([+-*/]{1}(?'kh'()*((? 检查括号是否配对

Related labels:
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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template