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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Python regular express...
Power Automate
Answered

Python regular expression (regex) not working

(0) ShareShare
ReportReport
Posted on by 116

I specifically want to find sequences of 4 digit numbers and exclude all matchs that are greater than 4 digits long. To do this, I use the \b sequence. If you test the following regex on a regex testing website like regex101.com, you'll see that the regex works as expected: \b\d{4}\b

However, when I use this sequence in Power Automate in a Python Script, nothing is found. How do I fix this issue? Is this a bug in Power Automate Desktop? If it matters, I am reading from Excel files to find these 4 digit number sequences. I have tested direct copy-paste of these Excel files contents and the regex once again worked as expected. It is only in Power Automate Desktop that it stops working.

I have the same question (0)
  • MichaelAnnis Profile Picture
    5,727 Moderator on at

    Power Automate uses .NET expressions, not Python.  I don't know much about Regular Expressions, but hopefully this can help you.

    https://docs.microsoft.com/en-us/dotnet/standard/base-types/regular-expression-language-quick-reference

     

  • comma Profile Picture
    116 on at

    \b is listed under Anchors: https://docs.microsoft.com/en-us/dotnet/standard/base-types/regular-expression-language-quick-reference#anchors

     

    I am running Python in PAD by using the action "Run Python script": https://docs.microsoft.com/en-us/learn/modules/pad-scripting/2-scripting-actions

    I am also new to regex so I may be misunderstanding something but regex is a universal "language" so it should work the same way in any app.

  • Verified answer
    Rkv_ Profile Picture
    166 on at

    You can use the Parse Text action within the Power Automate Desktop and apply the regular expression on a text.

  • comma Profile Picture
    116 on at

    This is the one! Thanks! Now, I'm just wondering why Python doesn't seem to process the regex correctly...

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 267 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 196

#3
Haque Profile Picture

Haque 182

Last 30 days Overall leaderboard