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.
正如评论中提到的,正则表达式不能改变匹配的文本,它只是匹配或不匹配。
如果您愿意在第一个逗号处停止匹配,而不是在删除逗号的情况下包括所有其余部分,则可以使用以下命令:
(?<=<title\>)(.*?)(?=(,|\s*<\/title>))
https://regex101.com/r/PPb1ba/1