MatchAll

How to Use the Power Fx MatchAll  Function in Power Apps

What is the Power Fx MatchAll Function?

The MatchAll function is a powerful function in Power Apps that is used to search for a specific pattern or substring in a string. The function searches for all occurrences of the pattern or substring in the string and returns an array of all the matches. The MatchAll function is case-insensitive, meaning that it will search for matches regardless of the case of the pattern or substring.

Syntax of the MatchAll Function

The syntax of the MatchAll function is as follows:


- String: The string that is to be searched for the pattern or substring.

- Pattern: The pattern or substring that is to be searched for in the string.

Using the MatchAll Function

To use the MatchAll function in Power Apps, you need to follow the steps below:

1. Create a new canvas app or open an existing one.

2. Add a text input control to the app.

3. Set the Default property of the text input control to a string that contains the pattern or substring that you want to search for.

4. Add a button control to the app.

5. Set the OnSelect property of the button control to the following formula:


6. Replace “Pattern” with the pattern or substring that you want to search for.

7. Run the app.

8. Enter the string that you want to search for the pattern or substring in the text input control.

9. Click the button control.

The MatchAll function will search for all occurrences of the pattern or substring in the string entered in the text input control and return an array of all the matches. The Matches collection will be populated with the array of matches.

You can then use the Matches collection to display the matches in a gallery or a table control.

Example

Let’s say you have a text input control that contains the following text:


This is an example text that contains the word "example" multiple times.


You want to search for all occurrences of the word “example” in the string. To do this, you need to follow the steps below:

1. Create a new canvas app or open an existing one.

2. Add a text input control to the app.

3. Set the Default property of the text input control to the following string:


This is an example text that contains the word "example" multiple times.


4. Add a button control to the app.

5. Set the OnSelect property of the button control to the following formula:


6. Run the app.

7. Enter the string "This is an example text that contains the word 'example' multiple times." in the text input control.

8. Click the button control.

The Matches collection will be populated with the array of matches, which in this case is:


[

{

“Start”: 11,

“End”: 18,

“Match”: “example”

},

{

“Start”: 45,

“End”: 52,

“Match”: “example”

}

]


You can then use the Matches collection to display the matches in a gallery or a table control.

The MatchAll function is a powerful function in Power Apps that is used to search for a specific pattern or substring in a string. By following the steps outlined in this article, you can easily use the MatchAll function in your Power Apps to search for patterns or substrings in strings. Use the Matches collection to display the matches in a gallery or a table control. With the MatchAll function, you can easily create powerful applications that can be used on different devices.

Power Apps Training Courses by G Com Solutions (0800 998 9248)