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

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 12:26:04
Original
1121 people have browsed it

正则效率太低有没有办法用其它办法代替
要把   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);
Copy after login
Array<br />(<br />    [ab] => 100<br />    [bc] => 200<br />    [cd] => 300<br />)<br /><br />
Copy after login
效率低吗?没看出来

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template