cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Advocate IV
Advocate IV

Editor bug with regex? Type detection fails

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.

7 REPLIES 7
Highlighted
Super User
Super User

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 );
Highlighted
Advocate IV
Advocate IV

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.

Highlighted
Super User
Super User

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

Highlighted
Advocate IV
Advocate IV

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).

Highlighted
Super User
Super User

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


@iAm_ManCat

Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


Highlighted
Advocate IV
Advocate IV

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.

Highlighted
Super User
Super User

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.

Helpful resources

Announcements
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Users online (4,268)