Quantcast
Channel: Adobe Community: Message List - ColdFusion
Viewing all articles
Browse latest Browse all 21760

Re: String Functions to extract first name initial and first 5 letters of last name

$
0
0

Actually, now that I think about it.. even if first and last name are in the same field or variable, as long as middle name/initial are not being used, you can still do it, simply.

 

fullname = "Reese Witherspoon"; 
concat = left(ListGetAt(fullname,1," ",true),1) & left(ListGetAt(fullname,2," ",true),5);

 

^_^

 

UPDATE: Minor modification.  This works as long as the last name isn't something like "Van ****" or "Van Zandt".  SOOOOOOOO, check the list length (with " " as delimiter) and if it's greater than two, join positions 2 through x together, removing all spaces.

 

fullname = "Dick Van George Jettson"; // It didn't like D y k e.. sigh.. 
thisLen = listLen(fullname," "); // 4  if (thisLen eq 2){   concat = left(ListGetAt(fullname,1," ",true),1) & left(ListGetAt(fullname,2," ",true),5);}else{   concat = left(ListGetAt(fullname,1," ",true),1);   lastname = "";   for(i = 2; i lte thisLen; i=(i+1)){      lastname &= ListGetAt(fullname,i," ",true);      }    concat &= left(lastname,5);}

Viewing all articles
Browse latest Browse all 21760

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>