cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper II
Helper II

Help with Regular expression for Valid Folder names

Hi guys

 

W2 have a data card, with a text input, that we need to validate that the text file does not contain any special characters... 

If(
     IsMatch(
          TrimEnds(txtAccountName.Text),
          "*:<>/\|?"
          ),
    Blank(),
     TrimEnds(txtAccountName.Text)
)
 
We tried escaping the character, we tried not escaping, we tried the Contains option, but still no luck 😞
 
What is the code to fail the validation, if the string contains any of the above character?
 
Thanks in advance. 
 
Fadi
 
 
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Helper II
Helper II

The only way around this, is to use multiple lines!!! I am sure there is a better way.. .


If(
IsMatch(txtProjectName.Text,"<",MatchOptions.Contains) Or
IsMatch(txtProjectName.Text,">",MatchOptions.Contains) Or
IsMatch(txtProjectName.Text,"\*",MatchOptions.Contains) Or
IsMatch(txtProjectName.Text,":",MatchOptions.Contains) Or
IsMatch(txtProjectName.Text,"/",MatchOptions.Contains) Or
IsMatch(txtProjectName.Text,"\\",MatchOptions.Contains) Or
IsMatch(txtProjectName.Text,"\?",MatchOptions.Contains) Or
IsMatch(txtProjectName.Text,"\|",MatchOptions.Contains)
,
Blank(),
TrimEnds(txtProjectName.Text)
)

View solution in original post

4 REPLIES 4
Highlighted
Helper II
Helper II

The only way around this, is to use multiple lines!!! I am sure there is a better way.. .


If(
IsMatch(txtProjectName.Text,"<",MatchOptions.Contains) Or
IsMatch(txtProjectName.Text,">",MatchOptions.Contains) Or
IsMatch(txtProjectName.Text,"\*",MatchOptions.Contains) Or
IsMatch(txtProjectName.Text,":",MatchOptions.Contains) Or
IsMatch(txtProjectName.Text,"/",MatchOptions.Contains) Or
IsMatch(txtProjectName.Text,"\\",MatchOptions.Contains) Or
IsMatch(txtProjectName.Text,"\?",MatchOptions.Contains) Or
IsMatch(txtProjectName.Text,"\|",MatchOptions.Contains)
,
Blank(),
TrimEnds(txtProjectName.Text)
)

View solution in original post

Highlighted

Hi @3ation ,

 

I preformed some tests on my end and was only able to Match the expression with the special characters by dividing the expression into multiple lines, given that if you insert all of the characters into the pattern it will only count if it finds all from that sequence.

The only operator you can use in the function currently looking at the documentation is the  operator as shown:
image.png

 

You can refer to the documentation in here: https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-ismatch

 

Hope this helps!

 

Regards,

Ricardo

 

Highlighted

Thanks @rimatos,

 

Not so "Regular Expression" after all.  The whole idea of regular expressions is to avoid the multiple lines (and the hit in performance). Thank you for trying. We keep hitting these odd situations... 

 

Highlighted

Hi @3ation ,

 

Sorry for not being able to provide you with the desired outcome for this.

One last suggestion that I offer is to leave a post on our Ideas Forum with this topic as a feature suggestion to be reviewed by our Product Group. Additionally you can always search for another existing idea and upvote it in order to bring visibility.

 

If you like you can leave the Idea here in the thread in order for people that find this behavior can upvote as well.

 

Regards,

Ricardo

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (3,861)