How to convert javascript regex to safe java regex?

前端 未结 3 490
广开言路
广开言路 2020-12-17 20:43
strOutput.replace(\"/{{[^]*?}}/g\",\"\");

Is there a way to convert JavaScript regexes to Java-safe regexes?

The above statement gives me t

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-17 21:23

    Get rid of "/" and "/g" at the start and the end of regex. Then you need to escape every "\" occurrence like so: "\\".

    The "g" part means global. This is controlled in how you use regex in Java as opposed to in the regex string.

提交回复
热议问题