using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"\b(?:in|and|is)\s+((?:.(?!\b(?:in|and|is)\b))*(?:HomeStay|Luxury)(?:.(?!\b(?:in|and|is)\b))*)(?!.*(?:HomeStay|Luxury).*)";
string input = @"Hello, tonight I'm in the town of Trenton in Hotel HomeStay [123] in New Jersey and I will be staying in Hotel HomeStay [123] and I have no money. Actually, I'm wealthier than this guy outside, I will be staying in Hotel HomeStay [123] and I have tons of money. in Hotelin HomeStay [123in]. HomeStay and never gonna give you up, never gonna make you cry. This is Luxury, and a cheeseburger.
";
RegexOptions options = RegexOptions.Multiline;
foreach (Match m in Regex.Matches(input, pattern, options))
{
Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
}
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx