Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试创建一个匹配引号的正则表达式,但不是连续两个引号,所以:
' --> match, '' --> no match and ''' --> match the last '
我试过:
(?<!')'
但它不起作用……</p>
提前谢谢!
也许试试这个:
(?<!')(?:'')*(')(?!')
正则表达式101演示
您可以使用此正则表达式匹配最后一个引号(单引号或双引号):
"((['\"]){2})*\\2"
代码:
String repl = "'''".replaceAll("((['\"]){2})*\\2", "$1:"); //=> '':