Regex expression not working for exact comparision

Hi all,
I need to compare 4 digits.It works fine with the code,but if i have given 5 digits also its showing
True instead of triggering false.I need suggestion regarding the issue.Main.xaml (7.2 KB) regex.xlsx (7.3 KB)

1 Like

we can directly mention the expression in IF condition like this
CompanyCode.ToString.Length<=4 AND System.Text.RegularExpressions.Regex.IsMatch(CompanyCode.ToString,“[\d]{4}”)
image

Cheers @raghuramk

Hi @raghuramk,
Unfortunately, your activity with the regex is unavailable to me, but just a question: did you mark e.g. with “\b” the boundaries, like here: \b[0-9]{4}\b

yes @PAD.I have done it still not working

@raghuramk what’s your regex? What exactly do you have in m1?

@PAD \b\d{4}\b is the regex

That’s odd - as I am getting “False” with my “Is Match”

did this expression helped us along the IF Condition
@raghuramk

Thank you so much the issue is resolved
cheers @Palaniyappan

1 Like

Cheers @raghuramk

1 Like