Jose L Martinez-Avial
Jose L Martinez-Avial

Reputation: 2265

Java RegExp escape repeated single quote

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

Upvotes: 3

Views: 528

Answers (1)

Kent
Kent

Reputation: 195039

are u looking for this?

"(?<!')'(?!')"

Upvotes: 3

Related Questions