Using the following code, results in the "ResultOfIsMatch" variable being set to "false" when it should be set to "true". See screenshots showing IsMatch evaluates to true but variable is set to false. This code was used on the app's OnStart property. (Code below is obviously using a regex that will always evaluate to true, but this is just for the purposes of demonstrating the issue.)
If(
IsMatch(
User().Email,
"\.\*"
),
Set(ResultOfIsMatch, true),
Set(ResultOfIsMatch, false)
)
Similarly, trying to set a variable to the value returned by IsMatch sets the variable to false.
Set(
ResultOfIsMatch,
IsMatch(
User().FullName,
"\.\*"
)
)
Am I simply using this function wrong? This is not the behavior I would expect.
Solved! Go to Solution.
Can you provide a string that you would expect a match with the expression "\.\*" ? The only way I can get this expression to evaluate as true is to have a string as ".*"
Are you trying to validate that a string is a correctly formatted email address? If so, there is a built in regex for that:
Set(
ResultOfIsMatch,
IsMatch(
varUser.Email,
Email
)
)
No. I was originally trying to verify the domain used in the email address (i.e. "@domain.com"); however, it doesn't matter what you are testing. Even when IsMatch evaluates to "true" the value passed along to the variable is "false" regardless of using an If statement or using Set.
If you'll note, I used a second example with User().FullName in an attempt to show that it doesn't matter what is being evaluated.
Set(
ResultOfIsMatch,
IsMatch(
User().Email,
Email
)
)
Try the formula I pasted above, this evaluated the variable 'ResulOfIsMatch' to true as expected in my environment.
Can you provide a string that you would expect a match with the expression "\.\*" ? The only way I can get this expression to evaluate as true is to have a string as ".*"
I added the backslashes because the formula was reporting an error at one point, but the error was something else and I left the backslashes in without thinking about it. The issue was that I was using the function wrong. My bad.
Below code works fine.
Set(myVar, IsMatch(User().Email, ".*@domain\.com"))
User | Count |
---|---|
250 | |
105 | |
82 | |
51 | |
43 |