AnsweredAssumed Answered

How to remove content within round brackets in a string in Velocity?

Question asked by Cristina Leonetti on May 16, 2019
Latest reply on May 16, 2019 by Cristina Leonetti

We want to have FirstName LastName (Abbr.) displayed as FirstName LastName.

I'm trying with regex but is not working, I'm new in velocity, and I would like kindly ask what's wrong in the script:

 

I tried this version:

#set ($string = ${lead.Account_Owner__c})
#set ($var1 = $string.replace("/\(\w+\)/", ""))
This is the Account Owner Without Abbreviation: $var1

 

This is not removing anything.

-----

 

This the other version I tried:

#set ($string = ${lead.Account_Owner__c})
#set ($var1 = $string.replace(/\(\w+\)/, ""))
This is the Account Owner Without Abbreviation: $var1

 

This script gives an error.

 

Thanks in advance!

 

Cheers,

Cristina

velocity my tokenvelocity script velocity error velocity scripting

Outcomes