标签:tar regex 选中 array target sea var php val
1、选中被逗号(或其他符号)分割的字符串当中的某一个值
69,23,69,88,695,69,69,6,765769fd969690,3242,969,69
实例,选中以上字符串所有出现的69部分
(\b69\b[,]?)|([,]?\b69\b)
javascript
var val = "69"; var exp = new RegExp("(\\b"+val+"\\b[,]?)|([,]?\\b"+val+"\\b)","g");
php
$matches = array(); $search = ‘69,23,69,88,695,69,69,6,765769fd969690,3242,969,69‘; $target = ‘69‘; $pattern = ‘/(\b‘.$target.‘\b[,]?)|([,]?\b‘.$target.‘\b)/‘; preg_match_all ($pattern, $search, $matches);
标签:tar regex 选中 array target sea var php val
原文地址:http://www.cnblogs.com/yiyide266/p/7199134.html