Possible Duplicate:
Regex matching left single quotation outside the double quotations
First Note:
&ldquo - left double quote (")
&rdquo - right double quote (")
&lsquo - left single quote (')
&rsquo - right single quote (')
I need to match all "Left single quote" that are not inside of left and right double quote.
For clarricifcation:
This is a
“sample &lsquo string &rsquo &rdquo
-> this should not be match because the&lsquo
(single quotes) is inside the double quoteThis is a
&lsquo sample &rsquo
-> the &lsquo should be match because that is not inside the double quotation
Here's my current regex:
(?<!.*&ldquo)&lsquo(?!.*&rdquo)
The problem with this is, it is looking both the &ldquo
and &rdquo
, if any of ldquo and rdquo occure, it will not match
for example:
This is a
&lsquo sample &rdquo
-> I need to match &lsquo here but because of the appearance of &rdquo, the regex didn't matchThis is
&ldquo a string &lsquo sample
-> same problem with no.1 example
Hope somebody can help me! thanks!