Home  >  Article  >  Backend Development  >  正则效率太低有没有办法用其它办法替代

正则效率太低有没有办法用其它办法替代

WBOY
WBOYOriginal
2016-06-13 12:26:041059browse

正则效率太低有没有办法用其它办法代替
要把   ab100bc200cd300 这个字符串格式化为 ab=>100、bc=>200、cd=300,也就是英文+数字
使用正则虽然可以,但是效率性能太低,有没有办法用其它方实现呢?求大神解答
------解决思路----------------------

$s = 'ab100bc200cd300';<br />preg_match_all('/([a-z]+)(\d+)/', $s, $m);<br />$t = array_combine($m[1], $m[2]);<br />print_r($t);
Array<br />(<br />    [ab] => 100<br />    [bc] => 200<br />    [cd] => 300<br />)<br /><br />
效率低吗?没看出来

Statement:
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