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
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

Jaspal Singh
Mega Patron
Mega Patron

Try below.

/\[[0-9]{4}+-[a-zA-Z]{4}+-[0-9]{4}+]/g

Matt102
Giga Guru

fwiw

var eSubject = '[8795-WSDG-8348] [208e7252]';
var regex = /\[[0-9]{4}-[A-Z]{4}-[0-9]{4}\]/;
var ticketNum = eSubject.match(regex);
gs.info(ticketNum);

hth,matt