Converting ″Straight Quotes″ to “Curly Quotes”

后端 未结 7 1073
旧时难觅i
旧时难觅i 2020-12-13 19:53

I have an application which uses a Javascript-based rules engine. I need a way to convert regular straight quotes into curly (or smart) quotes. It’d be easy to just do a <

7条回答
  •  天涯浪人
    2020-12-13 20:22

    'foo "foo bar" "bar"'.replace(/"([-a-zA-Z0-9 ]+)"/g, function(wholeMatch, m1){
        return "“" + m1 + "”";
    });
    

提交回复
热议问题