Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Editor bug with regex? Type detection fails

(0) ShareShare
ReportReport
Posted on by 241

I ran into the following problem while writing a formula. I boiled it down to the following simple example:


This works correctly:

Set( data, "regexdata" );
Set( regex, Match( data, "regex(?<h>.*)" ) );
Set( data, regex.h );

The global variable 'data' is assigned a text value, and after that the regular expression is used to update the value. (You could demonstrate this by displaying the value of the 'data' variable on a label).

However, if I add an extra line :

Set( data, "regexdata" );
Set( rawdata, data );
Set( regex, Match( data, "regex(?<h>.*)" ) );
Set( data, regex.h );

The editor starts throwing errors, indicating incompatible types.

Categories:
  • timl Profile Picture
    34,935 Super User 2025 Season 1 on at
    Re: Editor bug with regex? Type detection fails

    @iAm_ManCat - Thanks for the code. It's useful to see how setting a interim variable fixes the problem. It's extra evidence that this is indeed a bug.

    Set( Data2, regex.h );
    Set( Data, Data2 )

    I also now notice that wrapping Text around regex.h removes the error.

    image.png

    @MrNappa - thanks for sharing this problem. Hopefully, Microsoft will fix this. If this sort of problem forces you to revert to a previous version, it sounds serious. I'm glad you didn't lose much work though.

  • MrNappa Profile Picture
    241 on at
    Re: Editor bug with regex? Type detection fails

    Yeah, thanks for the suggestion. Actually the extra variable is not necessary but I was having a bit of trouble with my regular expression so I added the extra variable to catch the 'raw' value of the string being regexed so I could debug it better. That's when I ran into this.

  • Verified answer
    iAm_ManCat Profile Picture
    18,201 Most Valuable Professional on at
    Re: Editor bug with regex? Type detection fails

    Hi,

     

    Yes, I agree this is a bug with how the string within the Match value is being read against other string values - you can use a second variable to get around it though:

     

    Set( Data,"regexdata" );
    Set( rawdata, Data );
    Set( regex, Match( Data, "regex(?<h>.*)" ) );
    Set( Data2, regex.h );
    Set( Data, Data2 )

     

    Cheers,

    Sancho

  • MrNappa Profile Picture
    241 on at
    Re: Editor bug with regex? Type detection fails

    Yeah, I'm pretty sure it's a bug too, the automatic type detection algorithm can be a bit off at times. The app where I first experienced this is a lot more complex, and I had the editor freeze on me in the formula that contained a structure similar like this. After that the app failed to load, so I had to revert it to a previous version 😅. (luckily not much was lost, this was the only formula I had been working on since the last stable save).

  • timl Profile Picture
    34,935 Super User 2025 Season 1 on at
    Re: Editor bug with regex? Type detection fails

    Hi @MrNappa 

    Unfortunately, I don't know what the cause of this problem is. "regexdata" and regex.h are both of type string, so the syntax should be correct. I think there might be a bug in the editor or PowerApps.

    Perhaps someone else might be able to look at this and spot what's wrong?

     

    image.png

  • MrNappa Profile Picture
    241 on at
    Re: Editor bug with regex? Type detection fails

    No, this example was done on a new empty blank canvas app, I only added a button and put this formula in the 'OnSelect' handler.

  • timl Profile Picture
    34,935 Super User 2025 Season 1 on at
    Re: Editor bug with regex? Type detection fails

    Hi @MrNappa 

    Have you used the variable rawdata elsewhere in your app and assigned it a data value that isn't of type string? That would be a possible cause of the problem.

    Can you rename rawdata to rawdata2 and see if the problem goes away? If so, that would confirm the hypothesis.

    Set( data, "regexdata" );
    Set( rawdata2, data );
    Set( regex, Match( data, "regex(?<h>.*)" ) );
    Set( data, regex.h );

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,635 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,997 Most Valuable Professional

Leaderboard