Parse Function - substringBetween



I am trying to use the string parsing method on the message body of an incoming HTML email. I can get this to partially match, but the output contains some new lines/carriage returns. My goal is to try and match on the new line in the message.substringBetween parse, so that I only output a single concise line of text.

Input I am trying to parse:

(New Line)

Parse I am using:




Non-working desired command


Desired output:

P.S. I have also tried RegEx extract and that is a nightmare. I can partially get matches. Things that work in regex testers perfectly won’t translate over to opsgenie unfortunately.

If regex is the way to go. My problem there is for some reason it wont match on a space. I have tried to escape the space as a test, i.e. “Message-ID\ \n”


Hi Matt!

I think you were working on this with us in our chat support last week when you got up to this point. Would it be possible to head back to our chat and send over a “raw” copy of the email (save a copy and attach the file)? I’d expect something like what you have, {{message.substringBetween(“Message-ID\n<”,"<mailto:")}}, to work but obviously something else is preventing a match.

Checking the HTML version that’s attached to the alert shows something different from what we appear to be processing:

Chaining two substringBetween functions (with the first one you listed then a second to remove the “\n<”) might also help in this case.


@Robert, thank you for the help on this! OpsGenie support is great! We were able to work on this together and quickly came to a solution.

For those interested we were able to get a match using, {{message.substringBetween(“Message-ID\r\n\r\n<”,"<")}}

The parse is able to interpret Newline \n and Carriage return \r.