Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java RegExp escape repeated single quote

Tags:

java

regex

I'm trying to split a string by single quotes, but taking into account that a repeated single quote represents a escaped quote. So for example the following string

String ss ="aaa''bbb'ccc''ddd'eee";

would be splitted in

aaa''bbb
ccc''ddd
eee

so the regular expression should be something like "Any single quote that is not preceded by a single quote and its not followed by a single quoted". The expression to avoid the single quote not followed by a single quote is simple:

String regexp= "'(?!')";

But I was unable to apply the condition "not preceded by a single quote". Any ideas?

TIA

JL

like image 456
Jose L Martinez-Avial Avatar asked Dec 31 '25 08:12

Jose L Martinez-Avial


1 Answers

are u looking for this?

"(?<!')'(?!')"
like image 102
Kent Avatar answered Jan 01 '26 21:01

Kent



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!