[急][在线]两个简单的问题,请大家帮忙看看 2.$str="<a><m><d><a><a><c><a><c>test";$find_str="<a>";$count=substr_count($str,$find_str); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 多谢bluemeteor第二个问题已经解决 <?php$s = "<a><m><d><a><a><c><a><c>test";preg_match_all("/<a>[^a]*test/",$s,$regs);echo $regs[0][0]; // <a><c>test?> 如果不是<a>,该怎么写[^a]呢?例如:<test><b><te><v><tes><c><test><test>aaaa如何用preg_match_all得到距离aaaa最近的<test> 其实是这样[^a]代表本表达式不匹配"[]"内出现的字符a,比如:[^test]表示不匹配t、e、s等如果需要不匹配字符是一组怎么表示,坛子里有个帖子说是x(?!y)的方式,我不是很明白帖子:http://expert.csdn.net/Expert/topic/2298/2298360.xml?temp=.4160578--------------------------------------------------------------------一个简单的应用:你如何判断超文本同类标签的嵌套??<b>aaa<b>bbb</b>aaa</b>我的要求是从最小的单元由里向外解释!!就是截取到 "b" 标签中不再包含"b"标签的 字符串-------------------------------------------------------------------- 我已经不行了,想要说的表达不出来,急死了(?!a){3} 什么意思?手册上讲的是:(?!a){3}并不是断言下面三个字符不是“a”,而是断言下一个字符不是“a”三次。 干脆哪位讲讲正则表达式的不跟随模式是怎么回事吧谢谢了 这没有一定的样式,都弄弄就是了$s = "<test><b><te><v><tes><c><test><test>aaaa";preg_match_all("/.*(<test>.*aaaa)/",$s,$regs);print_r($regs); <?php$s = "windows 3.1";preg_match_all("/windows (?!95|98|200)/",$s,$regs);print_r($regs); //out Array ( [0] => Array ( [0] => windows ) ) $s = "windows 2000";preg_match_all("/windows (?!95|98|200)/",$s,$regs);print_r($regs); //out Array ( [0] => Array ( ) ) $s = "windows 3.1";preg_match_all("/windows (?=95|98|200)/",$s,$regs);print_r($regs); //out Array ( [0] => Array ( ) ) $s = "windows 2000";preg_match_all("/windows (?=95|98|200)/",$s,$regs);print_r($regs); //out Array ( [0] => Array ( [0] => windows ) ) ?> php守护进程之终极守护......... apache链接mysql出错~~求解~~~ PHP如何获取XML节点中属性的值呢 帮我看看这个正规表达式有什么样的作用? php能不能post一个二进制格式的数据? 数组转换,急... php系统外网访问速度 请教个问题 本人急求主页的图片动态转换可链接的原码.那么好心人帮忙啊? 如何判断一个指定的目录是否为空? php中的md5和asp中写成的md5算法为什么不同?巨急? 急!!(菜鸟的问题)
$s = "<a><m><d><a><a><c><a><c>test";preg_match_all("/<a>[^a]*test/",$s,$regs);
echo $regs[0][0]; // <a><c>test
?>
<test><b><te><v><tes><c><test><test>aaaa如何用preg_match_all得到距离aaaa最近的<test>
[^a]代表本表达式不匹配"[]"内出现的字符a,比如:[^test]表示不匹配t、e、s等如果需要不匹配字符是一组怎么表示,坛子里有个帖子说是x(?!y)的方式,我不是很明白
帖子:http://expert.csdn.net/Expert/topic/2298/2298360.xml?temp=.4160578
--------------------------------------------------------------------
一个简单的应用:你如何判断超文本同类标签的嵌套??<b>aaa<b>bbb</b>aaa</b>我的要求是从最小的单元由里向外解释!!就是截取到 "b" 标签中不再包含"b"标签的 字符串
--------------------------------------------------------------------
手册上讲的是:(?!a){3}并不是断言下面三个字符不是“a”,而是断言下一个字符不是“a”三次。 干脆哪位讲讲正则表达式的不跟随模式是怎么回事吧谢谢了
$s = "<test><b><te><v><tes><c><test><test>aaaa";
preg_match_all("/.*(<test>.*aaaa)/",$s,$regs);
print_r($regs);
$s = "windows 3.1";
preg_match_all("/windows (?!95|98|200)/",$s,$regs);
print_r($regs); //out Array ( [0] => Array ( [0] => windows ) ) $s = "windows 2000";
preg_match_all("/windows (?!95|98|200)/",$s,$regs);
print_r($regs); //out Array ( [0] => Array ( ) ) $s = "windows 3.1";
preg_match_all("/windows (?=95|98|200)/",$s,$regs);
print_r($regs); //out Array ( [0] => Array ( ) ) $s = "windows 2000";
preg_match_all("/windows (?=95|98|200)/",$s,$regs);
print_r($regs); //out Array ( [0] => Array ( [0] => windows ) ) ?>