How to Check if a String Contains Numbers in Power Automate?

Last week, while working with a client, I got an interesting requirement: they needed to check if a string contained any numbers in Power Automate. At first, it seemed like a simple task, but as I explored different approaches, I found two interesting ways to achieve this.

In this tutorial, I will tell you how to check if a string contains numbers in Power Automate using a combination of expressions and actions.

Check if a String Contains Numbers in Power Automate

Now I will show you two different ways to check if a string contains numbers in Power Automate:

Check if a String Contains Numbers Using Select Action

Recently, I had a requirement to check if a string contained numbers using Power Automate. For example, if a user entered “Text123”, the flow should identify that numbers are present and return True. But if the input was just “Text”, it should return False.

1. Create a new Instant Cloud Flow and choose Manually trigger a flow as the trigger. Then, expand the trigger action and add a Text input field where users can enter the string to check.

power automate string contains number

2. Add an Initialize Variable action and add the below parameters to create a reference list of numeric values (0-9) that we will use to check against the input string:

  • Name: Numbers
  • Type: Array
  • Value: Provide expression to create an array of numbers from 0 to 9:
createArray('0','1','2','3','4','5','6','7','8','9')
power automate string contains any number

3. Add the Select action and add the below parameters:

  • From: Provide the below expression to generate an array of positions in the input string:
range(0, length(triggerBody()['text']))

With the help of this, we check through each character in the input string to check if any of them are numbers.

  • Map: Provide the below expression to check each character against the initialized Numbers array:
if(contains(variables('Numbers'), slice(triggerBody()['text'], item(), add(item(), 1))), true, false)
How to check if a String contains Numbers using Power Automate flow

4. Add a Condition action to check if the Select output contains true:

power automate check if string contains numbers

5. Then in the true section, add a Compose action that outputs The input string contains numbers and in the false section, add a Compose action that outputs The input string doesn’t contain any numbers.

check if a String contains Numbers in Power Automate

Save and run the flow manually, then provide the string like EnjoySharePoint123.

check if a String contains Numbers in Power Automate flow

After the flow runs successfully, Expected Output: True (The input string contains numbers).

Check if a String Contains Numbers using Select Action in power Automate

Check if a String Contains Numbers Using Expression

Imagine you have a SharePoint list named Customer Requests with a column called Request Details (Single line of text):

check if a String contains Numbers in Power Automate flows

Where users submit their requests. Sometimes, users include reference numbers or invoice IDs within the request details, and you must identify entries containing numbers.

Now to do this follow the below steps:

1. Create an Automated Cloud Flow using the SharePoint connector’s ‘When an item is created‘ trigger. Select the SharePoint site where your ‘Customer Requests‘ list is present, and choose the ‘Customer Requests‘ list.

check if string contains numbers using flow

2. Add a compose action and provide the following expression:

or(contains(triggerBody()?['RequestDetails'], '0'), contains(triggerBody()?['RequestDetails'], '1'), contains(triggerBody()?['RequestDetails'], '2'), contains(triggerBody()?['RequestDetails'], '3'), contains(triggerBody()?['RequestDetails'], '4'), contains(triggerBody()?['RequestDetails'], '5'), contains(triggerBody()?['RequestDetails'], '6'), contains(triggerBody()?['RequestDetails'], '7'), contains(triggerBody()?['RequestDetails'], '8'), contains(triggerBody()?['RequestDetails'], '9'))
Check if a String Contains Numbers using Expression in Power Automate

3. Add a Condition action to check if the compose output is equal to true:

Power Automate Check if a String Contains Numbers using Expression

4. Then, in the true section, add a Compose action that outputs The input string contains numbers; in the false section, add a Compose action that outputs The input string doesn’t contain any numbers.

check if a String contains Numbers in Power Automate

Save the flow, go to the SharePoint list Customer Requests, and add an item.

How to Check if a String Contains Numbers in Power Automate

After the flow runs successfully, check the compose output.

Power Automate flow Check if a String Contains Numbers using Expression

Conclusion

In this tutorial, I explained two methods for checking if a string contains numbers in Power Automate. The first approach used the Select action, where we compared each character in the input string against a predefined array of numbers (0-9). The second approach relied on an Expression that checked if any numeric character was present in a SharePoint list column.

You may like:

>

Build a High-Performance Project Management Site in SharePoint Online

User registration Power Apps canvas app

DOWNLOAD USER REGISTRATION POWER APPS CANVAS APP

Download a fully functional Power Apps Canvas App (with Power Automate): User Registration App

Power Platform Tutorial FREE PDF Download

FREE Power Platform Tutorial PDF

Download 135 Pages FREE PDF on Microsoft Power Platform Tutorial. Learn Now…