email notification

YUVRAJS
Tera Contributor

Hii Team, 

  i want to create a regex or a pattern which can be used to filter data based on following criteria

     Exclude names which starts with "!" 

 

Screenshot 2024-06-27 155429.png

1 ACCEPTED SOLUTION

Gaurav Vaze
Kilo Sage

Try to use the following pattern

^(?!\!).*


Mark it as helpful if it worked
     Gaurav Vaze
ServiceNow Developer

View solution in original post

6 REPLIES 6

Anurag Tripathi
Mega Patron
Mega Patron

This works 

regex = /^!/;

 

Try this in a background script

 

var regex = /^!/;
var name = "!test";
var result = regex.test(name);
gs.info(result);

 

-Anurag

Hii @Anurag Tripathi   

    i am getting the result as "true" for the script you have mentioned.  but what i need is that the name which starts with ' ! ' should not be shown in the list.

can you please confirm.

Thanks

 

its the same,

You can try with different test case is name and test. it will return true when ! is at the start.

!youvraj

You!raj

Youvraj!

 

-Anurag

Robbie
Kilo Patron
Kilo Patron

Hi @YUVRAJS,

 

Confirming via regex tester (https://regex101.com/), try the following:

- /^[!]

- (or) /^[!]/gm

 

However, key question, can I ask why we need a 'regex match' for a check when a name starts with? You can easily manage this via the 'starts with' condition.

 

Screenshot 2024-06-27 at 15.26.08.png

 

 

To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.


Thanks, Robbie