Utilize RegExp in Inbound email action

Afsar2
Tera Contributor

 

Hi guys,

I am trying to utilize regular expression in an Inbound Email Action script.

I am trying to parse an email body (email.body_text) and extract few line between 2 keywords.

Regular Expression Pattern: '/Address:(.*?)Phone Number/s'

The above pattern is valid verified at https://regex101.com/

Syntax in the script is as follows.

var regExp = new RegExp('/Address:(.*?)Phone Number/s');
var body_text = email.body_text.toString();
var extract_address = body_text.match(regExp);

 

in the log statement "extract_address" is null.

I am not sure why it is happening so.

Any suggestions will be of great help.

Thank you

 

 

 

1 ACCEPTED SOLUTION

Hi @Afsar 

sorry my bad. Please use the following modified expression

/Address:([\S\s]+?)Phone Number/g

Kind regards
Maik

View solution in original post

6 REPLIES 6

Thanks for the response and glad that it is working for you now.

Hi,

Following this thread. I am working on inbound email action to write a regular expression to identify external reference number and if the number matches to the subject line (short description) of the incident, it should update. If the reference number ( "/ref #\[0-9]{20}/" ) does not match it should create an incident. Can you please help me on this. Thanks in advance