A
C
D
I
R
S
T
What is the IsMatch function?
The IsMatch function is a Power Fx function that is used for pattern matching. It takes two parameters: the first parameter is the string that you want to check and the second parameter is the pattern that you want to match against. If the string matches the pattern, the function returns true. Otherwise, it returns false.
Using the IsMatch function in Power Apps
The IsMatch function can be used in many different ways in Power Apps. Here are some examples of how to use it:
Checking if a string matches a specific pattern
Let’s say you have a text input control in your app, and you want to make sure that the user enters a valid email address. You can use the IsMatch function to check if the entered string matches the email address pattern. Here’s how to do it:
IsMatch(TextInput1.Text, “b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+.[A-Z|a-z]{2,}b”)
This expression will return true if the text in the TextInput1 control matches the email address pattern.
Checking if a string matches any pattern from a list
You can also use the IsMatch function to check if a string matches any pattern from a list. Let's say you have a list of valid phone number patterns, and you want to check if a string matches any of them. Here's how to do it:
Or(
IsMatch(TextInput1.Text, “^d{3}-d{3}-d{4}$”),
IsMatch(TextInput1.Text, “^(d{3}) d{3}-d{4}$”),
IsMatch(TextInput1.Text, “^1-d{3}-d{3}-d{4}$”)
)
This expression will return true if the text in the TextInput1 control matches any of the phone number patterns in the list.
Using the IsMatch function in a formula
You can also use the IsMatch function in a formula to perform conditional logic. Let's say you have a button that should only be enabled if the text in a text input control matches a certain pattern. Here's how to do it:
If(IsMatch(TextInput1.Text, “^[A-Za-z]+$”), true, false)
This expression will return true if the text in the TextInput1 control matches the pattern of only alphabetic characters, and false otherwise.
The IsMatch function is a powerful tool that you can use in Power Apps to perform pattern matching. Whether you need to validate user input, match against a list of patterns, or perform conditional logic, the IsMatch function can help you achieve your goals. By following the examples in this article, you should now have a good understanding of how to use the IsMatch function in your Power Apps.