Skip to main content
Level 2
Jun 9, 2022 12:22 PM UTC
Solved

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. 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
SanfordWhiteman
SanfordWhitemanAccepted solution
User Group Leader
Jun 13, 2022 6:38 PM UTC

OK, sounds like Velocity is the way to go.

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

 

3 replies

SanfordWhiteman
User Group Leader
User Group Leader
Jun 9, 2022 3:50 PM UTC

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

Translate
PMarketoAuthor
Level 2
Jun 13, 2022 10:34 AM UTC

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

Translate
SanfordWhiteman
User Group Leader
SanfordWhitemanUser Group LeaderAccepted solution
User Group Leader
Jun 13, 2022 6:38 PM UTC

OK, sounds like Velocity is the way to go.

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

 

Translate