正则问题
两个例子:
86AA4NP4210950SM
86AAUWPB2112507E
求红色部分的结果。
我写的正则:
- PHP code
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->preg_match_all('/([a-zA-Z0-9][\w\s]{1}\w{2})\w{2}(\d{4})\w{4}/',$s1,$r1);
print_r($r1);
只能匹配第二个例子。求能同时满足例一例二的正则表达式。
------解决方案--------------------
你这个用什么正则啊,直接substr()多好
- PHP code
$stra='86AA4NP4210950SM';
$strb='86AAUWPB2112507E';
$a = substr($stra,2,4);
$b = substr($stra,8,4);
<br><font color="#e78608">------解决方案--------------------</font><br>最啊,不是很规律吗,<br>从第3个字符substr到第6个<br>再从第9个substr到12不就完事了吗 <div class="clear">
</div>









