Power Automate

Wildcards in Power Automate: Use String Functions Instead

Power Automate Switch cases use exact values. Route variable text safely with startsWith, contains, substring and guarded examples.

Collab365 Team · Published 23 April 2026 · Refreshed 24 August 2026 · 2 min read

Power Automate's Switch control is for exact case values. If you need wildcard-like matching, calculate a predictable value first or use string functions in a Condition.

Microsoft's expression cookbook documents substring(), contains() and other supported patterns. The full workflow expression reference is the authority for function behaviour.

Route by a fixed character

For a reference such as LM004646, where the second character identifies an office:

substring(variables('Reference'), 1, 1)

Put the result in a Compose action, then Switch on M, L or the other valid codes.

The index is zero-based. Guard against blank or one-character inputs before calling substring():

greaterOrEquals(length(coalesce(variables('Reference'), '')), 2)

Send invalid values to an exception path. Do not let them disappear into a default branch with no log.

Match a prefix

Use a Condition with:

startsWith(toLower(variables('Reference')), 'lm')

Normalising both sides makes the comparison case-insensitive.

Match text anywhere

contains(toLower(triggerBody()?['subject']), 'invoice')

This is useful for broad routing, but it can match more than intended. invoice also matches not-an-invoice. Use structured fields or exact codes for high-impact decisions.

Match several known shapes

Use conditions from most specific to least specific, or derive a routing key in Compose and switch on that key. This is easier to test than a dense nested expression.

Create test cases for:

  • a valid match
  • different letter casing
  • blank input
  • input shorter than expected
  • extra leading spaces
  • an unknown code

About regular expressions

Do not assume a regex() function exists in your cloud-flow expression environment because another Microsoft product uses Power Fx or because Copilot suggested it. The previous article mixed Power Fx claims into cloud-flow expressions without reliable support.

When the pattern is genuinely complex, use a supported connector, desktop flow, Azure Function or another approved service that explicitly provides regular expressions. That adds operational and licensing considerations, so prefer ordinary string functions where they are sufficient.

The maintainable pattern is simple: validate the input, derive a small routing key, use Switch for exact cases and make the exception branch visible.

Need help reducing a brittle routing expression? Join Power Automate Builders.