web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details
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. 

I have the same question (0)
  • WarrenBelz Profile Picture
    149,732 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
    149,732 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

MS.Ragavendar – Community Spotlight

We are honored to recognize Ragavendar Swaminatha Subramanian as our September…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 733 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 532 Super User 2025 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 399 Super User 2025 Season 2

Last 30 days Overall leaderboard
Loading started
Loading started
Loading complete