[英]Regex - Replace only if the pattern is not inside a quote
假设我想写一个正则表达式来用单词Cat
替换单词Dog
。
例如
Dogs are scary.
会变成:
Cats are scary.
但我希望只有在单词 Dog 不在引号内时才应用此正则表达式。
例如
Dogs are scary but my mom told me that "Dogs are cute"
会变成:
Cats are scary but my mom told me that "Dogs are cute"
我不知道该怎么做。 请帮帮我 :)
对于更完整的功能,如果您需要变量来控制替换,请参阅https://stackoverflow.com/a/69428257/1432181了解类似问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.