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 / Using Regular Expressi...
Power Automate
Answered

Using Regular Expressions in Power Automate Desktop - I am getting a syntax error when using Parse Text

(0) ShareShare
ReportReport
Posted on by 34

I am trying to extract one or two names from a text string. The string can be a single name or two names with variations listed below. I used regex101.com to generate and test the regx, I am assigning variable names to each portion of the regular expression, so I repeat the Parse text command for each variable to extract.  I have six Parse Text commands to grab all the data from the string. Here is the regx and sample data. I get a syntax error when I use the generated regx. I removed the '^' and the '$' but I still get the error. The first and second middle Initial are optional, and there may not be a second name.

 

Regx: 

^(?<LAST_NAME>[\w]+)\s(?<FIRST_NAME>[\w]+)(\s?(?<MID_INITIAL>[\w]+)([%+]((?<LAST_NAME2>[\w]+)\s)?(?<FIRST_NAME2>[\w]+)\s(?<MID_INITIAL2>[\w]+))?)?$

 

Sample Data:

LAST_NAME FIRST_NAME MID_INITIAL

LAST_NAME FIRST_NAME MID_INITIAL+FIRST_NAME2 MID_INITIAL2

LAST_NAME FIRST_NAME MID_INITIAL%FIRST_NAME2 MID_INITIAL2

LAST_NAME FIRST_NAME MID_INITIAL+LAST_NAME2 FIRST_NAME2 MID_INITIAL2

LAST_NAME FIRST_NAME MID_INITIAL%LAST_NAME2 FIRST_NAME2 MID_INITIAL2

LAST_NAME FIRST_NAME

LAST_NAME FIRST_NAME+FIRST_NAME2 MID_INITIAL2

LAST_NAME FIRST_NAME%FIRST_NAME2 MID_INITIAL2

LAST_NAME FIRST_NAME+LAST_NAME2 FIRST_NAME2 MID_INITIAL2

LAST_NAME FIRST_NAME%LAST_NAME2 FIRST_NAME2 MID_INITIAL2

I have the same question (0)
  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    The syntax error is caused by the percentage symbol, because PAD reserves that for variable notation.

    If you want to pass a literal % into the string, you need to escape it with another %. Try this:

    ^(?<LAST_NAME>[\w]+)\s(?<FIRST_NAME>[\w]+)(\s?(?<MID_INITIAL>[\w]+)([%%+]((?<LAST_NAME2>[\w]+)\s)?(?<FIRST_NAME2>[\w]+)\s(?<MID_INITIAL2>[\w]+))?)?$

    -------------------------------------------------------------------------
    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.

    I also provide paid consultancy and development services using Power Automate. If you're interested, DM me and we can discuss it.

  • Srini007 Profile Picture
    3,473 Super User 2026 Season 1 on at

    Hi @chucknb28409 

     

    As @Agnius said you have %, which is treated as an end/start of a variable, for example in Regex we will use escape character  like \%, like this we need to give "%%"(Double %)  in PAD

     

    If you find this reply helpful, please consider giving it a LIKE AND

    If this reply answers your question or solves your issue, please ACCEPT AS SOLUTION

     

    Thanks,

    Srini

  • chucknb28409 Profile Picture
    34 on at

    Hi Angnius,

    I am not sure what happened when I posted (I didn't check the insert) but here is what is actually on regx101.com and in Power Automate. For some reason it doubled the back slashes and I didn't catch it...

    Thanks

  • chucknb28409 Profile Picture
    34 on at

    Hi Agnius,

    Okay I corrected it but I still get a syntax error. See attachment.

    Thanks

  • Verified answer
    Srini007 Profile Picture
    3,473 Super User 2026 Season 1 on at

    Hi @chucknb28409 

     

    Still, there is a single % it should be rectified with %%

     

    Srini84_0-1697631485908.png

     

    If you find this reply helpful, please consider giving it a LIKE AND

    If this reply answers your question or solves your issue, please ACCEPT AS SOLUTION

     

    Thanks,

    Srini

  • Verified answer
    Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    The specific flavor of Regex that PAD uses is not exactly the same as that in regex101. I would recommend using http://regexstorm.net/tester instead. It works in 100% cases.

     

    Also, you have not actually done what I suggested. Please just make sure that you put in double percentage symbols instead of a single percentage symbol - i.e. do %% instead of %.

    This will clearly not work on any regex tester, because they don't use % as an escaping character, but PAD does - this is because % is a reserved character in PAD for variable notation, and it can never be used as a single %.

    -------------------------------------------------------------------------
    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.

    I also provide paid consultancy and development services using Power Automate. If you're interested, DM me and we can discuss it.

  • chucknb28409 Profile Picture
    34 on at

    Hi Agnius,

    I did what you suggested and the syntax error went away, what I don't understand is why. When you want to examine a range of characters don't you put them in brackets? I have two options there is either a plus (+) or a percentage (%) separator between multiple names. When I did the double percentage (%%) it took that and changed the input to ("%"+) inside of square brackets in Power Automate. Is this something unique to dot Net? Also regx101.com has an option for dot Net as the language flavor and it doesn't show the change. In regexstorm.net I can't get it to work at all so I will have to play with it. I am wondering if regexstorm.net is having issues with the variable assignment?

    Thanks

  • Verified answer
    Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    This is not related to regex in any way. It is a thing specific to PAD, because, as we have mentioned it is used for variable notation in PAD. When you escape it with another %, that's what it looks like.

    -------------------------------------------------------------------------
    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.

    I also provide paid consultancy and development services using Power Automate. If you're interested, DM me and we can discuss it.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at
    You can handle this type of exception by adding two extra percent signs. exp %'%'%
    Screenshot.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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 664

#2
Haque Profile Picture

Haque 460

#3
Valantis Profile Picture

Valantis 357

Last 30 days Overall leaderboard