开发者

Javascript Regex: PHP like Callback Variable

开发者 https://www.devze.com 2023-02-21 14:56 出处:网络
In PHP I ca开发者_StackOverflow中文版n get back the results from subpaterns like this: preg_replace(\"/(a-z)/im\", \"$1\", $string);

In PHP I ca开发者_StackOverflow中文版n get back the results from subpaterns like this:

preg_replace("/(a-z)/im", "$1", $string);

But is this possible in javascript?


Almost exactly the same way:

"foo".replace(/f(o*)/, "found: $1");

gives "found: oo".

0

精彩评论

暂无评论...
验证码 换一张
取 消