Skip to content


Parse Contact Name

Bill asked 5 years ago
Is there a function to parse a contact name (Mike J Lee, Mike Smith) to get first name Mike and last name Lee?
Thank you!
Patrick Roth Staff answered 5 years ago
There isn’t anything in smartconnect that would do this automatically.
However asking google, I found a couple of links I like:
There are others.
Obviously it is way easier to put a full name together than split one out but with some assumptions that should be do-able.
The thing interesting in your example is that one has 3 values and the other just 2.  So you would have to adapt for that as well.
Using the string.split() method is your best bet and then if you have 3 elements in your array you would guess you have first/middle/last.  And if have two then just first/last.
And if just one – then either Prince, Madonna, or Cher (ie first name only)

If you would like to submit an answer or comment, please sign in to the eOne portal.