web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Condition to check for...
Power Automate
Unanswered

Condition to check for characters in string

(0) ShareShare
ReportReport
Posted on by 104

All, 

 

I have this output that will contain random numbers/text. I would like to create a condition step that will check if this Video.3 contains any digit or text, 

 

If it contains characters then move to "YES"

 

If it does not contain any characters then move to "NO",

 

Does anyone know how I can set this up? 

 

aishak12_0-1668387673018.png

 

Categories:
I have the same question (0)
  • v-chengfen-msft Profile Picture
    on at

    Hi @aishak12 ,

    Do you want to determine if Video.3 contains a character?

    Please try to use regex to achieve.

    There is a connector for this to work with regular expressions:

    Plumsail SP - Connectors | Microsoft Learn

    Here is a test for your reference:

    If the Video.3 content is not a number, it[IsSuccess] will return false.

    vchengfenmsft_0-1668396882767.png

    Here is result:

    vchengfenmsft_1-1668397237184.png

    vchengfenmsft_2-1668397243343.png

    Here are some links for your reference:

    What is a Regular Expression? [Components & Examples] | Liquid Web

    How to use match, test, replace regular expressions in Microsoft Power Automate and Azure Logic Apps and PowerApps | by Oleg Tsurkan | Plumsail | Medium

     

    Best Regards

    Cheng Feng

  • aishak12 Profile Picture
    104 on at

    any way to do this with the "Condition" step? I don't want to use 3rd party tools.

  • grantjenkins Profile Picture
    11,063 Moderator on at

    If you didn't want to use a Third-Party solution, you can use Office Scripts within Excel. The first thing you will need to do is create a script that you can then use within Power Automate.

     

    It's important to note that when you create an Office Script it's stored in your One Drive, and if you want others to use it you will need to share it with them. There is now an option to save your Office Scripts in a SharePoint Library, but unfortunately (at this stage) you can't then use them within Power Automate.

     

    To create a new Office Script, create/open an Excel File in the Browser and click on Automate on the Toolbar, then click on New Script.

    grantjenkins_0-1668478803336.png

     

    In the Script code editor that appears, Rename the script to something like regExMatch, then paste in the following which is a script that uses Regex.

    function main(
     workbook: ExcelScript.Workbook,
     searchString: string,
     regexPattern: string,
     regexFlags: string): Array<string> {
     const matches: Array<string> = [];
     const re = new RegExp(regexPattern, regexFlags);
     const matchArray: Array<string> = searchString.match(re);
    
     if (matchArray) {
     matchArray.forEach(m => matches.push(m))
     }
    
     return matches;
    }

    grantjenkins_1-1668478959648.png

     

    You can now use that script in any of your Power Automates.

     

    For your requirement, see the flow below. I'll go into each of the actions.

    grantjenkins_2-1668479053618.png

     

    Compose holds the data you want to check which may or may not contain characters.

    grantjenkins_3-1668479133743.png

     

    Run script is an Excel Online action that you can use. It doesn't matter what Excel file you choose here as the Office Script itself lives in your OneDrive.

    grantjenkins_4-1668479210740.png

     

    Script will be the script that you just created. It should show up as an option to select.

    searchString is the text you want to check. In this case it's whatever is stored in our Compose.

    regexPattern is the same as @v-chengfen-msft provided which will match if the searchString contains only numbers.

    regexFlags has g to not just look at the first match.

     

    The result will be either an array of matches, or if no matches, an empty array. So, your Condition can check the length of the result (array). If it equals 0 then the text must have included characters other than numbers. If it contains 1 or more items in the array, then it only includes numbers.

     

    The expression to check the length of the array is:

    length(outputs('Run_script')?['body/result'])

     

    grantjenkins_5-1668479539459.png

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard