JavaScript - Using Regex to extract a specific value from body

Summary

In this example script it will use Regex for a matching value within the Email Body. If matched then it will add the extracted as the value for the Custom Field.

If you have to use “\”, you will need to ensure that you use “\\” instead. e.g. \\:\\sTEST

var regx = new RegExp("Ref:[0-9]+").exec(body); //Check Email Body for a match if(regx !== null) { print("matched value: " + regx[0]); //Prints out the matched value result.setValue(regx); //Sets the value to matched Regex }

Custom Field Validation output: