Inbound Action Regex for multiple line variable

mooreka777
Giga Contributor

Hello There SN Gurus!

I have a variable that spans multiple lines and I am trying to find an easy way to create a variable from the data. Basically I want to see if there is a way to capture everything from ^" to "$ using regex.

 

Example:

LONGDESC="asdf

asdf

asdf

asdf

asdf"

 

Here is some sample code that I found, but it isn't doing what I want

Example:

desc = parseVar[i].split('LONGDESC=')[1].toString().replace(/^\"|^\"|\"$/g, '');

 

Thanks for the help and guidance!

Kindly,

Kelly

 

1 ACCEPTED SOLUTION

Actually maybe try +11 to cater for the " mark!

View solution in original post

11 REPLIES 11

Chuck Tomasi
Tera Patron

I just tested this at rubular.com and was able to extract everything between the double quotes like this:

/^"(.*)"$/m

Your first group is going to contain the text, BUT you need to use the m modifier, not g.

You can find out more about RegEx in episodes 31 and 32 of TechNow.

TechNow Episode List

mooreka777
Giga Contributor

Thanks Chuck!

 

That is good feedback and I appreciate the link to the regex tester.  I tested the code on the inbound action and it still stops on a single line.

 

Any other ideas on what I can do to get the inbound action regex to match?

 

 

Kindly,

Kelly

 

 

Can you kindly share the inbound email action you've got right now?

mooreka777
Giga Contributor

Hello There,

 

I think I found the issue. The code is parsing by newline

var parseVar = email.body_text.split('\n');  

 

Is there a better way for me to parse the email?  Loading the entire thing into an array and then working from there, but we get a lot of email to this inbound action and want to ensure we keep the performance up.

 

Sample Email (as text)

%LONGDESC="mail eater on

multiple lines"

 

Inbound Action to Find:

 

desc = parseVar[i].split('%LONGDESC=')[1].toString().replace(/^"(.*)"$/m, '');