c# – Regex to match text Inside single quotes

I have been looking and testing many, many patterns that match text within quotes.

The best that I have found to date [on s/o] is (?<=([']\b))(?:(?=(\\?))\2.)*?(?=\1)

This is the best regex that I have found, since it allows for escaped single-quotes and will not include any characters in-between a previous match.

The main problem is that since it is using a \b, it will will never recognize text after the single-quote that is a non-word-boundary character.

I am okay at Regex, but this is currently beyond my ability.

Matches

I have been researching dozens of patterns from simple to complex – each seem to not meet the need of matching text within single or double-quotes, allowing for escaped single or double quotes, but not including anything between single or double-quotes that have been previously-matched.

Read more here: Source link