我怎么写这样的东西:
var s = "[hello world](one two)";
var x = s.replace(REGEX, '<p>$1</p><b>$2</b>');
输出:
<p>hello world</p><b>one two</b>
答案 0 :(得分:2)
console.log( "[hello world](one two)".replace(/\[(.*)\]\((.*)\)/, '<p>$1</p><b>$2</b>'));
答案 1 :(得分:1)
将以下正则表达式与negated character class一起使用。
var s = "[hello world](one two)";
var x = s.replace(/\[([^\]]*)]\(([^)]*)\)/, '<p>$1</p><b>$2</b>');
console.log(x);
答案 2 :(得分:0)
将捕获组与regex.exec(字符串)和this(([。])|((。)))+(或类似于此的东西)一起使用并构建theoputut字符串