Skip to main content

It seems like when I set up a pattern for a rule, for example: social security pattern: ^\d{3}-\d{2}-\d{4}$, with the option to replace it by "***", and I try the pattern by typing in "Here is my social: 111-11-1111". Then the pattern doesnt get applied. It will still show: Here is my social: 111-11-1111. But when I type in only the numeric pattern: 111-11-1111, it works. How can make sure the rule gets applied no matter what someone would type in before or after? 

 

 

Same with variations of a rule. Say I want to block the word "pancake" it works, but when I define the next pattern to be "pancakepanhandle" it only blocks out the "pancake" part, even though "pancakepanhandle" is also defined as a pattern for the rule. 

 

I am sure I am just setting it up incorrectly, so any help will be greatly appreciated! Thanks!
2 个回答
  1. 2022年6月7日 22:27
    \b(?:\d[ -]*?){9}\b

     

    @Nicole Loyal-Windham

     

    This pattern would find a 9 digit number anywhere in your text.

     

    It also allows there to be "spaces" or "-" in between the numbers.

     

    I've included some examples from https://regex101.com/ using this pattern with an example.

     

    \b(?:\d[ -]*?){9}\b This pattern would find a 9 digit number anywhere in your text. It also allows there to be

0/9000