Check if a string is with in the gorup of strings using regex

Hi
I am trying check if a string is within the group of words as mentioned below using regex.ismatch, but it is return False may be because it is checking the full string. Can you please help me to get the regex to check the below example
Example :
String to check : donotemail
String to be checked in : hello how are you, this is your robot signing in - thanks DonotEmail
Output : True

Hi @Harsha_Vemula

Can you try the below sample

System.Text.RegularExpressions.Regex.IsMatch("hello how are you, this is your robot signing in - thanks DonotEmail", "donotemail", System.Text.RegularExpressions.RegexOptions.IgnoreCase)

Note: Final variable datatype is System.Boolean

Cheers!!

Hi,

Can you try either of the following?

System.Text.RegularExpressions.Regex.IsMatch(yourString,"(?i)donotemail")

OR

System.Text.RegularExpressions.Regex.IsMatch(yourString,"donotemail",System.Text.RegularExpressions.RegexOptions.IgnoreCase)

image

Regards,

Why use RegEx? Just use contains:

stringToCheckIn.ToUpper.Contains(stringToCheck.ToUpper)

Hi @Harsha_Vemula

Try the below syntax:

strToCheck= "donotemail"
strToBeCheckedIn= "hello how are you, this is your robot signing in - thanks DonotEmail"
outputVariable= System.Text.RegularExpressions.Regex.IsMatch(strToBeCheckedIn, strToCheck, RegexOptions.IgnoreCase)

outputVariable is of DataType System.Boolean.
Note if you get an error RegexOptions is not declared please click on Imports and import System.Text.RegularExpressions

Regards

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.