Reputation: 1094
Is it possible to replace a single quote ' without affecting multi-single quotes (e.g. ''').
For example, I want to replace ' with '''
GIVEN --> EXPECT
-------------------------------------------
"text" --> "text"
"long'text" --> "long'''text"
"long'long''text" --> "long'''long''text"
"long'long'''text" --> "long'''long'''text"
"long'long'text" --> "long'''long'''text"
Thanks in advance
Upvotes: 1
Views: 101
Reputation: 784998
For matching use this look-around based regex:
(?<!')'(?!')
and replace it by:
'''
(?<!')'(?!')
matches a single quote if is not followed and preceded by a single quote.
Upvotes: 3