Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Regular expression to check email subject ref

James Rostron2
Mega Expert

Hi Community,

Looking for a bit of assistance in using RegEx in an inbound action to match a unique reference from a third party.

The end of the email always contains two sets of references like in the example below:

[8795-WSDG-8348] [208e7252]

I only need to match on the first set which is always a set of 4 numbers, 4 alphabetic characters and another 4 numbers (separated by dashes within brackets).

I've used the format below previously for a very simple number match just wondering if anyone can amend this for the scenario above.

var eSubject = email.subject;
var regex = /[0-9]+/;
var ticketNum = eSubject.match(regex);

Many Thanks,

James

1 ACCEPTED SOLUTION

Aishwarya Thaku
Tera Expert

Hi @James Rostron,

 

If you want to create a regex only for the first part i.e. [8795-WSDG-8348], the below regex may help you -

 

\[[0-9]+-[a-zA-Z]+-[0-9]+]

 

Please mark my answer as helpful or correct if applicable.

Thanks,

Aishwarya

 

View solution in original post

6 REPLIES 6

Aishwarya Thaku
Tera Expert

Hi @James Rostron,

 

If you want to create a regex only for the first part i.e. [8795-WSDG-8348], the below regex may help you -

 

\[[0-9]+-[a-zA-Z]+-[0-9]+]

 

Please mark my answer as helpful or correct if applicable.

Thanks,

Aishwarya

 

This is working perfectly Aishwarya.

Thanks for such a speedy solution!

James

 

Just to clear it will work but will accept characters or digits more than 4. Give it a check. 

Glad it helped you, James! Thanks for marking it as Correct 🙂 

 

Thanks,

Aishwarya