I have a string that I would like to return: hello\'world from the following string: 'hello\'world'
My regex pattern that currently does not work is the following: '[^']+'
This pattern gets all text that is within two single quotes. However, in my example, I would like it to ignore the single quote that has the \ character before it. Currently, my pattern above would return hello\ and another match as world
How can I achieve this desired result?
>Solution :
The following literally matches a quote (') then groups anything that follows ((.*)) that is followed by a quote (') not preceded by a slash (negative lookbehind: (?<!\\))
'(.+)(?<!\\)'