lastname = "DE' CA-R LO III"
'separate lastname by spaces into an array
a = split(lastname," ")
new_lastname = a(0)
for i = 0 to ubound(a) -1 ' add each chunk of the last name to the final string
'the last piece of the last name is not added if it is less than 4 characters (such as III, II, I, etc)
if i + 1 = ubound(a) and len(a(i+1)) > 3 then
new_lastname = new_lastname + a(i+1)
elseif i + 1< ubound(a) then
new_lastname = new_lastname + a(i+1)
end if
next
new_lastname = Replace(new_lastname,"-","") 'take out hyphens
new_lastname = Replace(new_lastname,"'","") 'take out punctuations
wscript.echo new_lastname
Thursday, September 3, 2009
Cut out unwanted pieces of a lastname with vbscript
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment