在 PHP 应用中,正则表达式主要用于:(1)正则匹配:根据正则表达式匹配相应的内容.(2)正则替换:根据正则表达式匹配内容并替换.(3)正则分割:根据正则表达式分割字符串
常用:preg_match_all()
preg_match_all() 函数用于进行正则表达式全局匹配,成功返回整个模式匹配的次数(可能为零),如果出错返回 FALSE 。
语法:int preg_match_all( string pattern, string subject, array matches [, int flags ] )
实例:$str = "之二宽阔的甘家口东#标签1#标签2 #标签3。#标签4,都发$1234 ¥xc,cvm , ¥12,dflksjf如何#标签5.x,代码如下:
- #tag6.cvxcv“";
- preg_match_all('/#([a-zA-Z0-9x7f-xff]+)/', $str, $mat);
- print_r($mat);
- preg_match("/[x{00a5}x{ffe5}](d+)/u", $str, $mat);
- print_r($mat);
正则匹配中文汉字根据页面编码不同而略有区别:
GBK/GB2312编码:[x80-xff>]+ 或 [xa1-xff]+
UTF-8编码:[x{4e00}-x{9fa5}]+/u
例子,代码如下:
- <?php
- $str = "学习php是一件快乐的事。";
- preg_match_all("/[x80-xff]+/", $str, $match);
- //UTF-8 使用:
- //preg_match_all("/[x{4e00}-x{9fa5}]+/u", $str, $match);
- print_r($match);
- ?>
补充说明:双字节字符编码范围
1. GBK (GB2312/GB18030)
x00-xff GBK双字节编码范围
x20-x7f ASCII
xa1-xff 中文 gb2312
x80-xff 中文 gbk
2. UTF-8 (Unicode)
u4e00-u9fa5 (中文)
x3130-x318F (韩文
xAC00-xD7A3 (韩文)
u0800-u4e00 (日文)
波比源码 – 精品源码模版分享 | www.bobi11.com
1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
7. 本站源码并不保证全部能正常使用,仅供有技术基础的人学习研究,请谨慎下载
8. 如遇到加密压缩包,请使用WINRAR解压,如遇到无法解压的请联系管理员!
波比源码 » PHP正则表达式匹配字符串中的指定标签
波比源码 » PHP正则表达式匹配字符串中的指定标签
generic levofloxacin 250mg levaquin over the counter
cialis 20 mg cialis 36 hour price compare sildenafil 50mg cost
cialis 20mg prix sildenafil 200mg en ligne acheter 25mg viagra en ligne
buy ramipril 10mg altace for sale azelastine 10ml cost
order buspirone 5mg for sale buspirone 10mg drug cheap ditropan 5mg
zoloft 50mg usa Viagra alternative sildenafil generic
order revia without prescription letrozole 2.5 mg without prescription aripiprazole brand
tadalafil 20mg over the counter cialis professional order anafranil 50mg for sale
amlodipine generic buy tadalafil 5mg cialis next day delivery usa
methotrexate tablet reglan 10mg over the counter reglan 20mg over the counter
tadalafil for sale cialis 5mg pills sildenafil 50mg ca
best no deposit free spins poker online game cialis for sale
cheap essay help brand stromectol ivermectin us
deltasone 20mg price amoxil 1000mg cost buy generic amoxicillin 1000mg
best play money poker sites doubleu casino cheap cialis tablets
cash poker online free online slot machines modafinil 200mg uk
lasix 40mg canada order generic plaquenil 400mg order hydroxychloroquine sale
sildenafil cost sildenafil 50mg usa order rhinocort pills
purchase naprosyn without prescription cost prevacid prevacid 15mg oral
clarithromycin order purchase biaxin online order antivert 25 mg pill
order singulair 10mg sildenafil buy online sildenafil 25mg
stromectol buy uk order avlosulfon 100 mg for sale avlosulfon pills
best online gambling money games free online blackjack
buy adalat 10mg aceon online order fexofenadine 180mg over the counter
order doxycycline 200mg oral cleocin cleocin order online
do my term paper where can i buy a research paper purchase azulfidine without prescription
order generic mesalamine 800mg order mesalamine 800mg without prescription order avapro 300mg online
olmesartan 20mg price buy olmesartan 10mg online order depakote online
brand amoxicillin 1000mg buy amoxil 250mg pills generic ivermectin for humans
famotidine 20mg cheap purchase mirtazapine online order generic remeron 15mg
buy doxycycline 100mg medrol 8mg without a doctor prescription order medrol for sale
esomeprazole us biaxin drug order furosemide 40mg sale
I really love to read such an excellent article. Helpful article. Hello Administ . Onwin , Onwin Giriş , Onwin Güncel Giriş , Onwin Yeni Adres , onwin
generic minocin hytrin brand buy generic hytrin 1mg
buy glycomet without prescription calan order nolvadex 20mg us
order clomid sale lipitor brand order prednisolone 40mg generic
stromectol 0.1 best ed medication order deltasone 40mg sale
order accutane online cheap isotretinoin 20mg oral buy zithromax 500mg generic
doxycycline 200mg without prescription vibra-tabs order online order acyclovir
buy oxybutynin for sale buy generic prograf oxcarbazepine us
buy zocor 20mg pills order promethazine 25mg online sildenafil 50mg tablets
order ezetimibe without prescription sumycin online order generic methotrexate 10mg
buy warfarin pills for sale reglan pills allopurinol buy online