I'm trying to add an email script token that will take only part of the string BEFORE the opening parenthesis. So the string is "Hello (www.google.com)" then I only want "Hello".
This is for use in a Marketo email.
The code that I'm trying to use is:
#set ( $index = ${lead.zasset}.indexOf('(') )
#set ( $asset = ${lead.zasset}.substring(0, ${index}) )
${asset}
#end
But instead of it showing "Hello", it's giving me this error message:
"Cannot get email content- An error occurred when procesing the email Body!
Lexical error, Encountered: "i" (105), after : "." at unset[line 327, column 125] near
</div> </div> <div class="spacer" style="mso-line-height-rule:exactly;height:30px;font-size:30px;line-height:30px;margin-top:0;margin-bottom:0;margin-right:0"
Any help would be much appreciated!
Try:
#set ( $index = ${lead.zasset.indexOf('(')} )
#set ( $asset = ${lead.zasset.substring(0, $index)} )
$asset
#end
You only need the formal notation ${...} when there are ambiguous characters around, and its curly braces should contain the whole expression.