|
![]() |
#1 |
Участник
|
powerobjects: Checking for Consecutive Repeating Characters in PowerApps
Источник: https://www.powerobjects.com/2018/07...ers-powerapps/
============== ![]() Today’s blog will walk through how you can check for repeating characters within PowerApps. We at PowerObjects are excited about the functionality of PowerApps and their potential for reducing the time for developing mobile apps. There are many resources to get up and running, including our webinars. The challenge with checking for repeating characters is that the PowerApps platform does not allow for writing loops within the PowerApps designer. How can you check if char4 = char5 = char6 within a full string? The solution is to leverage regular expressions. JavaScript regular expressions work in PowerApps. The solution for this use case is to use the IsMatch (Text, Pattern [,Options]) function with the Contains option and combining special characters “.” and “\x” and “{n,m}” to get the desired regular expression pattern: (.)\x{n} Let’s walk through an example of how to apply these pieces by creating a simple screen. Steps overview:
![]() Step 2 ![]() Step 3 Set one icon to display and the other to not display if there are three consecutive repeating characters Input the following expressions in the Visible property of the icons: Icon 1: If(IsMatch(TextInput1.Text,”(.)\1{2}”,Contains),true,false) Icon 2: If(IsMatch(TextInput1.Text,”(.)\1{2}”,Contains),false,true) Let’s break down what each piece means: IsMatch – checks if the input text matches what you specify in this function (.) – match any character except a newline character \1 – remembers 1 preceding character {2} – matches at least 2 occurrences of the preceding character (exclude the “m” in {n,m} because we are not limiting the number of characters in the string) Contains – the string specified is within the input text ![]() Step 4 – Test it out The happy emoji should display only when there are no three consecutive repeating characters, including letters and numbers. ![]() ![]() Congratulations! You just executed a workaround for the known limitation that PowerApps do not support programming loops. This is particularly helpful if you need to validate password inputs. You can learn more about the Dynamics 365 Spring 2018 Update for PowerApps in this blog. Want to learn more about how PowerApps and Microsoft Business Applications can benefit your organization? Join PowerObjects, this year’s Platinum Sponsor, at the Microsoft Business Applications Summit on July 22-24 in Seattle. Register with our code: HCL100dc to receive a $100 discount. Happy Dynamics 365’ing! Источник: https://www.powerobjects.com/2018/07...ers-powerapps/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|
|
|