JavaScript equivalent of PHP's preg

I am using a simple regex to replace break tags with newlines:

br_regex = /<br>/;
input_content = input_content.replace(br_regex, "n");

This only replaces the first instance of a break tag, but I need to replace all. preg_match_all() would do the trick in PHP, but I'd like to know the JavaScript equivalent.


使用全局标志g

foo.replace(/<br>/g,"n")

非正则表达式全局替换的JS成语:

input_content.split('<br>').join('n')
链接地址: http://www.djcxy.com/p/2746.html

上一篇: Javascript将“'”替换为“''”

下一篇: 相当于PHP的preg的JavaScript