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.
从字符串中删除所有出现的 of ',除非单词以 s 结尾,如果单词以s'or结尾,'s则'保留在其中。所有其他出现都被删除。
'
s'
's
例子:
Andrea's -Stays as is Kids' - stays as is 'Kids' --> Kids Ki'd's' --> Kids'
到目前为止我想出了什么:
\'(?!s )
这与第一个示例匹配并忽略它。
这是它的工作原理
我有其他问题
'([^'\s]+)'
你可以试试这个。替换为\1.See demo。
\1
https://regex101.com/r/oF9hR9/2#python