Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Answered

Custom Restrictions regex flags case insensitive

Posted on by 35

Hello. I want to create a restriction that does case insensitive matching. For example, as per docs.microsoft.com/.../regular-expression-language-quick-reference

Pattern \b(?i)a(?-i)a\w+\b

Matches "aardvark", "aaaAuto" in "aardvark AAAuto aaaAuto Adam breakfast"

However when I try this in customer voice I get an error. It doesn't seem to like parenthesis

pastedimage1611673493768v1.png

  • Suggested answer
    RE: Custom Restrictions regex flags case insensitive

    Hey Jason,

    I tried with the gmail example above, and was working fine. Is the issue persistent? if so, please drop a note with the survey id and the regex over email to usrathna@microsoft.com, so that we can investigate more on this.

    Thanks!

  • JasonBini Profile Picture
    JasonBini 35 on at
    RE: Custom Restrictions regex flags case insensitive

    Hi Usha. The keystroke response time is very slow when answering this question. Takes about 2-3 seconds for the characters to appear, Perhaps it's the regex that's causing the slowness. I can send you the example if you want to check it out, let me know.

  • JasonBini Profile Picture
    JasonBini 35 on at
    RE: Custom Restrictions regex flags case insensitive

    ok I submitted the feature request. Please upvote if you agree: experience.dynamics.com/.../

  • Suggested answer
    RE: Custom Restrictions regex flags case insensitive

    Hi Jason,

    Thanks for confirming! I understand it is a roundabout & time-consuming method.

    Currently, we do not support passing flags directly from the regex expression (since technically, the flag is invoked during the regex function invocation). You can submit an idea for CV to provide support for regex flags at aka.ms/customervoiceideas.

    We will add it to the backlog and prioritize the feature depending on the popularity of the idea.

  • JasonBini Profile Picture
    JasonBini 35 on at
    RE: Custom Restrictions regex flags case insensitive

    ok that works but it's painful.

    why can't we set flags?

    ^[A-Za-z0-9._%+-]+@(?i)gmail.com$

  • Verified answer
    RE: Custom Restrictions regex flags case insensitive

    Hey Jason,

    Can you try the below? You can define what specific domain you want to check against.

    ^[\w+!#$%&'*+-/=?^_`{|}~.]+\@[gG][mM][aA][iI][lL]([\.])[cC][oO][mM]$

  • RE: Custom Restrictions regex flags case insensitive

    Hey Jason,

    We are checking into this and will get back to you shortly.

  • JasonBini Profile Picture
    JasonBini 35 on at
    RE: Custom Restrictions regex flags case insensitive

    Thanks Usha

    I want to restrict users to input an email address with specific email domain, for example @gmail.com.

    If they want to spell gmail.com, or Gmail.com, or GmAiL.CoM shouldn't matter. I'm not sure how to make the gmail and the com as case insensitive. Right now, the following will restrict them literally to gmail.com

    ^[A-Za-z0-9._%+-]+@gmail.com$

    Any help is appreciated. Thanks!

  • Suggested answer
    RE: Custom Restrictions regex flags case insensitive

    Hi there, 

    Customer Voice uses JavaScript Regular Expressions. More details on the patterns can be found here: 

    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions 

    For example I was able to test the following pattern which tests if the user enters a combination of alphabet followed by a letter:

    \w\d

    Hope this helps. Curious to understand more of your use-case and the question you are using the regex for - are you trying to check if the user (in his text question response) mentions some specific word?

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans