MAS
MAS

Reputation: 1

How do I remove characters before the dot in a first name using substring and index of functions in ampscript and Salesforce Marketing Cloud?

■ If there is a name is followed with middle initial and dot, for example,

"Sara N." then remove the dot and two characters before it so that it

becomes "Sara"

■ If there are two first names BUT no middle initial with dot at the end, for

example "Mary Kate" then keep both first names so that it stays as"Mary

Kate".

■ If there are two first names with a middle initial and dot at the end, such as

"Mary Kate F." then remove the dot and 2 characters before it so it

becomes "Mary Kate"

■ If there are 2 first names with a dash in-between but no middle initial or

dot at the end, such as "Mary-Kate" then ppts name would remain as

"Mary-Kate"

■ If there is dot and initial at the end such as "Mary-Kate P." then dot and two characters before it would be removed so that it would become

"Mary-Kate"

☐"Tucker" would remain as "Tucker"

■ "George J" would remain as "George J"

Tried with substring , subtract , index of functions to implement the mentioned conditions.

It is not working.

Could anyone please help me with this in omitting the characters from the string when there is a dot in the first name.

Upvotes: 0

Views: 440

Answers (1)

J C
J C

Reputation: 1

if you're still looking for an answer something like this might work.

    SET @FirstName = AttributeValue("FirstName")
    SET @FirstName = Substring(@FirstName,1, Subtract(IndexOf(@FirstName,"."),2))

This removes the first character before a period and anything after.

Upvotes: 0

Related Questions