Re: determining if a field contains a number

cslater
Level 2

determining if a field contains a number

Our data is a mess and some of our first name fields contain numbers. Is there a way to use velocity script to weed those users out. I am currently doing it this way, but I didn't know if there was an easier way.

#if ( $lead.FirstName.contains("1") && $lead.FirstName.contains("2") && $lead.FirstName.contains("3") && $lead.FirstName.contains("4") && $lead.FirstName.contains("5") && $lead.FirstName.contains("6") && $lead.FirstName.contains("7") && $lead.FirstName.contains("8") && $lead.FirstName.contains("9") && $lead.FirstName.contains("0"))
Hi there,
#else
Hi ${lead.FirstName},
#end
Tags (1)
2 REPLIES 2
cslater
Level 2

Re: determining if a field contains a number

I messed it up. It's actually:

#if ( $lead.FirstName.contains("1") || $lead.FirstName.contains("2") || $lead.FirstName.contains(".3) || $lead.FirstName.contains("4") || $lead.FirstName.contains("5") || $lead.FirstName.contains("6") || $lead.FirstName.contains("7") ||$lead.FirstName.contains("8") || $lead.FirstName.contains("9") && $lead.FirstName.contains("0") )
Email Friend,
#else
${lead.FirstName},
#end
SanfordWhiteman
Level 10 - Community Moderator

Re: determining if a field contains a number

#if( $lead.FirstName.matches(".*\d+.*") )
Email Friend,
#else
${lead.FirstName},
#end