I would like to write pattern for regular expression which will maintain the sequence of word.
For Example:
I have one string like below:
string input="I visited this place with my friends twice. Normal outdoor sitting but yet pleasing. Food is very delicious and sumptuous. However they highly lack in Service which they need to improve a lot. On both my visit they failed to deliver the complete order and on asking twice - thrice, they finally came after half and hour and said that \" sorry we didn't prepare that, shall we prepare it now\". It was pretty disappointing as it happened repeatedly. I would have giving this place a 5 star but due to their poor service I will give them just 2 Stars."
string strPattern = "(visit(.*?) this place)";
Match matchResult = Regex.Match(input, strPattern, RegexOptions.IgnoreCase);
while(matchResult.Success) {
Console.WriteLine(matchResult.Value);
matchResult = matchResult.NextMatch();
}
When i console it this gives the output like
1. visited this place
2. visit they failed to deliver the complete order and on asking twice - thrice,
they finally came after half and hour and said that " sorry we didn't prepare
that, shall we prepare it now". It was pretty disappointing as it happened
repeatedly. I would have giving this place
So, The first output(visited this place) is fine.
But the second one not proper because it is taking the part of input string starting from word "
visit" and ends with "
this place".
I need the output like visit this place,visiting this place,visited this place etc..
So, for the above input string output should be this only
1. visited this place
The pattern should be in this manner so that it will maintain the sequence between the word also.
Thanks.