正则表达式匹配左单引号的双引号外面单引号、双引号、正则表达式

2023-09-03 08:19:56 作者:別來無恙

请注意:

左双引号()=&放大器; ldquo

left double quotation (") = &ldquo

右双引号()=&放大器; rdquo

right double quotation (") = &rdquo

左单引号(')=安培; lsquo的

left single quotation (') = &lsquo

我目前的正则表达式是这样

My current regex is this

(?<!.*&ldquo.*)&lsquo

,匹配和放大器; lsquo的在这里(这是正确的):

It matches the &lsquo in here (which is right):

&ldquoThis is a sample&rdquo &lsquosample text

这也匹配和放大器; lsquo的在这里(我不希望发生的,因为单引号是左,右双引号内):

It also matches the &lsquo in here (which I don't want to happen because the single quote is inside the left and right double quote):

&ldquoThis &lsquois a sample&rdquo

我怎么能写一个正则表达式匹配每一个和放大器; lsquo的是不是左,右报价在

How can I write a regex that will match every &lsquo that are NOT inside the left and right quotation

感谢您的帮助!

推荐答案

如果我理解UR question..This可能是你想要的。

If I understood ur question..This may be what you want

(?<!&ldquo.*?)&lsquo(?!&rdquo)
 
精彩推荐
图片推荐