I need to remove all “‘s” from text, except word “let’s”.
For example: “jerry’s let’s cake’s” >> “jerry let’s cake”.
strText = Regex.Replace(strText, @"\b(?!let's)([a-z-]+)'s\b", @"$1");
– this works, but it takes long time on big texts.
strText = Regex.Replace(strText, @"\b(?!let's)(?<=[a-z-]+)'s\b", "");
- this one is not ignoring “let’s”
What am I doing wrong in the second statement?
The simple trick you missed is using
\bin the negative lookbehind :Working example: http://regexr.com?31g9c