In reference to my question Regex expression to match whole word with special characters not working ?,
I got an answer which said
@"(?<=^|s)" + pattern + @"(?=s|$)"
This works fine for all cases except 1 case. It fails when there is space in the pattern.
Assume string is "Hi this is stackoverflow" and pattern is "this " , then it says no matches. This happens because of an empty space after the actual string in pattern.
How can we handle this ? Ideally speaking it should say one match found !
See Question&Answers more detail:os