php函数preg_match_all的匹配用jquery如何写

WBOY
Release: 2016-06-13 13:10:33
Original
846 people have browsed it

php函数preg_match_all的匹配用jquery怎么写
$s = '@放@b3@c @d ceff @e';
$pattern = '/@[^\s|@]+/';
preg_match_all($pattern, $s, $match);
echo '

';
print_r($match);

结果:
Array
(
[0] => Array
(
[0] => @放
[1] => @b3
[2] => @c
[3] => @d
[4] => @e
)

)

php能匹配出所有的,换成Jquery的match却只能匹配出第一个@放,是怎么回事,怎么匹配出所有的?

------解决方案--------------------
var reg = /@[^\s|@]+/g;

g 全程的

有没有 g 的区别和
preg_match 和 preg_match_all
的区别一般
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!