cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MrNappa
Level: Powered On

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
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 );
MrNappa
Level: Powered On

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.

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

MrNappa
Level: Powered On

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

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




Don't forget to 'Mark as Solution' if a post answered your question and always 'Thumbs Up' the posts you like or helped you!
Highlighted
MrNappa
Level: Powered On

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.

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
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (5,143)