Tag Archives: How to match an apostrophe (‘) unless it is escaped (\’)?

How to match an apostrophe (') unless it is escaped (\')?

Is it possible to construct a regular expression for this? If so, I’d appreciate if someone shows how.

Use this regular expression:

It means match all apostrophe chars not preceeded by a backslash (the backslash is escaped itself because it is a special char for regexps)