how to write Regular expression to check two words exist in a string

  • Thread starter Thread starter Narayana Reddy GundReddy
  • Start date Start date
N

Narayana Reddy GundReddy

Guest
Dear all,

I have a requirement to check if two words exist in a string.

I have written below code, but that is not working. For example, in the below code, I want to have both words Hi and hello existing in the string, "check". How to write regular expression to have both words Hi and hello any where in the string.

Please advise and thank you for your time and suggestion.

=============================================

Regex rx = new Regex(@"(Hi&hello)");
string check = "Hi and hello every one";
if (rx.IsMatch(check))
{
Console.WriteLine("string contains either Odoo or #rules");
}
==============================================


Narayana Reddy G

Continue reading...
 
Back
Top