Skip to main content
Community site session details

Community site session details

Session Id : 7LZriZN6ZAKC7PmEREhkZW
Power Apps - Building Power Apps
Answered

IsMatch function with pattern (Optional Comma & Space)

Like (0) ShareShare
ReportReport
Posted on 16 Nov 2022 04:07:07 by 47

Hi Experts,

I would like to seek your assistance on the validation syntax for an "IsMatch" function.

  • This is a text input field.
  • The user should be able to input a minimum of one 7-digit number (or) multiple 7-digit numbers [separated by a comma & a space
  • Scenario1: one 7-digit number [8000000]
  • Scenario2: multiple 7-digit numbers [8000000, 8000001, 8000002, 8000003, 8000004]

Here is my formula,

IsMatch(
 TextInput2.Text,
 "\d{7}\,*\s*",
 MatchOptions.BeginsWith
)

This does not seem to be working, please assist. Thank you. 

  • WarrenBelz Profile Picture
    148,894 Most Valuable Professional on 16 Nov 2022 at 08:07:32
    Re: IsMatch function with pattern (Optional Comma & Space)

    Hi @Franklin_vaz ,

    The replacement of the space was "in case" one was put in as if I did not clean it up, the Split() parts could contain a space and therefore not pass validation, so yes, the results of your three points were intentional.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

  • Franklin_vaz Profile Picture
    47 on 16 Nov 2022 at 07:27:29
    Re: IsMatch function with pattern (Optional Comma & Space)

    Many thanks, @WarrenBelz for your quick response.

     

    Validation works, and I can understand your logic.

    Here is some feedback,

    • The validation returns "true" even if there is no space
    • But it ensures each number is 7 digits and is separated by a comma at least
    • ignoring if a space is given or not.

    Curious to ask; the test you did, was it the same case? 

  • Verified answer
    WarrenBelz Profile Picture
    148,894 Most Valuable Professional on 16 Nov 2022 at 04:46:24
    Re: IsMatch function with pattern (Optional Comma & Space)

    Hi @Franklin_vaz ,

    Best effort below (did my head in a bit, but seems to work on test model)

    With(
     {
     wText: 
     Substitute(
     TextInput2.Text,
     " ",
     ""
     )
     },
     If(
     Find(
     ",",
     wText
     ) = 0,
     IsMatch(
     wText,
     Digit & Digit & Digit & Digit & Digit & Digit & Digit
     ),
     With(
     {
     wStrings: 
     Split(
     wText,
     ","
     )
     },
     CountRows(
     Filter(
     wStrings,
     IsMatch(
     Result,
     Digit & Digit & Digit & Digit & Digit & Digit & Digit
     )
     )
     ) = CountRows(wStrings)
     )
     )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

     

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

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410 Super User 2025 Season 2

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 2

Loading complete