SOLVED

Removing last letter from name if ends with s

Go to solution
PMarketo
Level 1

Removing last letter from name if ends with s

Hi Champions,

I want to write a script to remove the last letter from First name if name ends with s.

For eg:

Dear Janis -> Dear Jani

Dear Kaspars -> Dear Kaspar

Dear Karlis -> Dear Karli

 

 Any help here is much appreciated. 

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Removing last letter from name if ends with s

OK, sounds like Velocity is the way to go.

#set( $lead.friendlyFirstName = $lead.FirstName.replaceFirst("(?i)s$","") )
${lead.friendlyFirstName}

 

View solution in original post

3 REPLIES 3
SanfordWhiteman
Level 10 - Community Moderator

Re: Removing last letter from name if ends with s

Easily done in Velocity, but what’s the actual use case here? Did you have a bad data load?

PMarketo
Level 1

Re: Removing last letter from name if ends with s

This is a salutation rule in Latvia, we intent to use local language salutation rules in email.

SanfordWhiteman
Level 10 - Community Moderator

Re: Removing last letter from name if ends with s

OK, sounds like Velocity is the way to go.

#set( $lead.friendlyFirstName = $lead.FirstName.replaceFirst("(?i)s$","") )
${lead.friendlyFirstName}