## Regular Expressions & Changes You Should Not Ignore
**Regular expressions** (often shortened to "regex") are like super powerful filters for text in the software development and scripting world. They help you find specific patterns within a string of characters.
><br>Power Apps _does_ support regular expressions, but only through three key functions:
>- **`IsMatch`**: Checks if text follows a pattern (like email validation)
>- **`Match`**: Extracts the _first_ text snippet matching a pattern.
>- **`MatchAll`**: Extracts _all_ text snippets matching a pattern.
>- Official documentation: [IsMatch, Match, and MatchAll functions](https://learn.microsoft.com/en-us/power-platform/power-fx/reference/function-ismatch)<br><br>
![[RegFunctions.png]]
## Incredible Benefits of Regular Expressions:
- **Precision**: They allow you to search for very specific patterns, like finding all email addresses in a text.
- **Efficiency**: You can automate tasks that would otherwise take a lot of manual effort.
- **Flexibility**: Regular expressions can be used in many different programming languages and tools.
![[regExBenefits.png]]
## Consider these Examples
1. 📧 **Extracting Email Addresses**
- **Task**: Find all email addresses in a text field.
- **How**: Use the `MatchAll` function with a regex pattern to extract email addresses. For example, `\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b`.
- **Use Case**: Validate or extract email addresses from user input.
2. 📞 **Validating Phone Numbers**
- **Task**: Check if a phone number is in the correct format (e.g., "123-456-7890").
- **How**: Use the `Match` function with a regex pattern like `\d{3}-\d{3}-\d{4}`.
- **Use Case**: Ensure phone numbers entered by users are correctly formatted.
3. 💬 **Finding Specific Words**
- **Task**: Check if a specific word is present in a text field.
- **How**: Use the `Contains` function for simple cases, or `Match` with a regex pattern for more complex searches.
- **Use Case**: Filter data based on specific keywords.
4. 🔢 **Extracting Numbers**
- **Task**: Extract all numbers from a text field.
- **How**: Use the `MatchAll` function with a regex pattern like `\d+`.
- **Use Case**: Automatically extract numerical data from text inputs.
5. 🔑 **Checking Password Strength**
- **Task**: Ensure a password meets certain criteria (e.g., contains at least one uppercase letter, one lowercase letter, and one number).
- **How**: Use the `Match` function with a regex pattern like `^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).{8,}
.
- **Use Case**: Implement password validation to enhance security.
## Good or Just Not Good Enough?
![[20250206-regular-expression-changes-sm.jpg]]
These examples illustrate how regular expressions can be used to solve common problems in Canvas Power Apps, even though Power Fx doesn't **officially support** **regular expressions** currently. Just yesterday (2/4/25), **Greg Lindhorst** (*who amazingly has avoided the lens of any digital camera since 1999, when the first camera phone came out, The **Kyocera VP-210**, with a 0.11MP resolution!* 😲) [announced that it is finally time to add regular expression support natively](https://github.com/microsoft/Power-Fx/discussions/2840) in the language:
![[greg-post.png]]
### Request for Feedback
In that discussion he asks for the community's input after reviewing [this particular document he created](https://github.com/microsoft/Power-Fx/blob/gregli/regex-min/docs/regular-expressions.md) which I have outlined here for convenience:
- [Regular expressions]()
- [Supported features](https://github.com/microsoft/Power-Fx/blob/gregli/regex-min/docs/regular-expressions.md#supported-features)
- [Literal characters](https://github.com/microsoft/Power-Fx/blob/gregli/regex-min/docs/regular-expressions.md#literal-characters)
- [Assertions](https://github.com/microsoft/Power-Fx/blob/gregli/regex-min/docs/regular-expressions.md#assertions)
- [Character classes](https://github.com/microsoft/Power-Fx/blob/gregli/regex-min/docs/regular-expressions.md#character-classes)
- [Quantifiers](https://github.com/microsoft/Power-Fx/blob/gregli/regex-min/docs/regular-expressions.md#quantifiers)
- [Groups](https://github.com/microsoft/Power-Fx/blob/gregli/regex-min/docs/regular-expressions.md#groups)
- [Comments](https://github.com/microsoft/Power-Fx/blob/gregli/regex-min/docs/regular-expressions.md#comments)
- [Inline Options](https://github.com/microsoft/Power-Fx/blob/gregli/regex-min/docs/regular-expressions.md#inline-options)
- [Options](https://github.com/microsoft/Power-Fx/blob/gregli/regex-min/docs/regular-expressions.md#options)
- [Contains](https://github.com/microsoft/Power-Fx/blob/gregli/regex-min/docs/regular-expressions.md#contains)
- [Complete](https://github.com/microsoft/Power-Fx/blob/gregli/regex-min/docs/regular-expressions.md#complete)
- [BeginsWith](https://github.com/microsoft/Power-Fx/blob/gregli/regex-min/docs/regular-expressions.md#beginswith)
- [EndsWith](https://github.com/microsoft/Power-Fx/blob/gregli/regex-min/docs/regular-expressions.md#endswith)
- [DotAll](https://github.com/microsoft/Power-Fx/blob/gregli/regex-min/docs/regular-expressions.md#dotall)
- [FreeSpacing](https://github.com/microsoft/Power-Fx/blob/gregli/regex-min/docs/regular-expressions.md#freespacing)
- [IgnoreCase](https://github.com/microsoft/Power-Fx/blob/gregli/regex-min/docs/regular-expressions.md#ignorecase)
- [Differences between implementations](https://github.com/microsoft/Power-Fx/blob/gregli/regex-min/docs/regular-expressions.md#differences-between-implementations)
### How Will It Turn Out?
How will regular expressions be handled across the Power Platform? That may be up [to you / your feedback](https://github.com/microsoft/Power-Fx/pull/2504)!<br><br>
><br>By [[Darren Neese]] on February 5th, 2025 (last update 2/6/25)<br><br>