且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

替换两个引号之间的字符串

更新时间:2022-12-10 23:28:16

str = "hello, my name is \"michael\", my friend's is \"bob\". what's yours?";
str.replace(/"([^"]+)"/g, '<span class="name">$1</span>');

输出:

hello, my name is <span class="name">michael</span>, my friend's is <span class="name">bob</span>. what's your's?