BA-IT
Tous les articles
Power Apps November 17, 2024 1 min

Using Regex in Power Apps' Find and Replace Text Functions

Power Apps has native support for regular expressions, but it stays hidden behind a handful of text functions. Once you know where to look, regex becomes one of the fastest ways to validate inputs and reshape strings inside canvas apps.

Where regex lives in Power Apps

Four functions accept a regular expression: IsMatch, Match, MatchAll and Substitute. The engine is based on .NET regex, so most patterns you know from other languages work directly.

IsMatch: validating an input

IsMatch returns a boolean. It is the go-to function to enforce a format on a TextInput, from email addresses to product references.

IsMatch(TextInput1.Text, "^[A-Z]{2}-\\d{4}$")

Combine it with the Match enum for well-known patterns:

IsMatch(TextInput1.Text, Match.Email)

Match and MatchAll: extracting data

Match returns the first occurrence, MatchAll returns a table of every match. Use named captures to access parts of the result.

MatchAll("Order#1234 total 42€", "(?<num>\\d+)")

Substitute vs regex replace

Substitute does not accept regex - it only matches literal strings. For pattern-based replacements, use the Match / MatchAll output combined with Concat, or split-and-rebuild with Split.

Common patterns

  • Email - Match.Email
  • French phone number - ^(?:+33|0)1-9{4}$
  • Postal code (France) - ^\d{5}$
  • SIREN - ^\d{9}$

Gotchas

  • Escape backslashes twice inside Power Fx strings.
  • MatchOptions.IgnoreCase and MatchOptions.Complete change the behavior - read the docs before assuming defaults.
  • Very long inputs can hit delegation limits when used in Filter clauses.

Wrap up

Regex inside Power Apps turns a chatty chain of Left/Right/Find calls into a single expressive line. Start with IsMatch for validation, then add Match/MatchAll as your data extraction needs grow.

Un projet Power Platform en tête ?

Cadrage, audit, développement ou déblocage d'urgence - parlons-en.