REGEX: Use IsMatch for exact match

Hi,

I want to match the exact string “ACCEPTED”, and not strings that may contain “ACCEPTED” like “PROBABLY ACCEPTED”. I tried the below but it doesn’t work.

System.Text.RegularExpressions.Regex.IsMatch(Q_Stat,”\b ACCEPTED \b")

Thank you.

Hi,

Hope the following expression helps you.

System.Text.RegularExpressions.Regex.IsMatch(Q_Stat,"^ACCEPTED$")

or you can also use the following expressions.

  (Q_Stat = "ACCEPTED")

 "ACCEPTED".Equals(Q_Stat)

Regards,

Hi

For the below, I get FALSE even when my string only has “ACCEPTED”

System.Text.RegularExpressions.Regex.IsMatch(Q_Stat,"^ACCEPTED$")

How do I use the below and get TRUE/FALSE and pass the result to a variable?

(Q_Stat = "ACCEPTED")

 "ACCEPTED".Equals(Q_Stat)

Thank you again!

Hi,

Can you try the following because probably your Q_Stat has some character such as white space?

System.Text.RegularExpressions.Regex.IsMatch(Q_Stat.Trim(),"^ACCEPTED$")

How do I use the below and get TRUE/FALSE and pass the result to a variable?

We can use assign activity.

booleanVar = (Q_Stat.Trim = "ACCEPTED")

booleanVar = "ACCEPTED".Equals(Q_Stat.Trim())

Regards,

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