I am using C# to find a phrase that may or may not exists in a blog posting. I need to capture the whole sentence that contains the target phrase.
I thought about using the string.contains method but that would return the whole blog post when all I want is the target phrase and its containing sentence.
Example:
I dont want this sentence. I also don't want this setence. But I do want this sentence.
So here the target phrase would be: “I do” and the regex should return the whole containing sentence “But I do want this sentence.”
Thanks.
Aaron
This regex :
When applied to your input :
Returns :
Turn on RegexOptions.Singleline if you worry about multiple lines.