简体   繁体   English

X或不是Y的正则表达式

[英]Regex for X or not Y

I have a long string of text that's broken up by semi-colons, so I have a regex that captures [^\\;]+ . 我有一长串用分号分隔的文本,所以我有一个捕获[^\\;]+的正则表达式。 However, it's bugging because the content contains HTML apostrophes ( ' ). 但是,这很麻烦,因为内容包含HTML撇号( ' )。

How can I write a regex that will capture everything but the semi-colons unless the semi-colon is part of the HTML apostrophe? 除非分号是HTML撇号的一部分,我如何编写一个能捕获除分号以外的所有内容的正则表达式?

(&\S+?;|[^;])+

匹配HTML实体,就好像它们是单个字符一样。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM