# Splitting a field containing people's names

**URL:** <https://forum.cloverdx.com/t/splitting-a-field-containing-peoples-names/1453>\
**Category:** CloverDX Platform\
**Created:** [July 9, 2014, 12:00am UTC](https://forum.cloverdx.com/t/splitting-a-field-containing-peoples-names/1453 "2014-07-09T00:00:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kcrane](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.cloverdx.com/kcrane/32/156_2.png) [@kcrane](https://forum.cloverdx.com/u/kcrane)\
**Post date:** [July 9, 2014, 12:00am UTC](https://forum.cloverdx.com/t/splitting-a-field-containing-peoples-names/1453/1 "2014-07-09T00:00:00Z")

</div>

Can anyone point me to the function I need to split a text field called “Full\_Name” into two fields called “First\_Name” and “Last\_Name”?

The Full\_Name field contains names of mixed length and number of text parts, example:  
Kevin Crane  
John Neal Smith  
Bill Preson-Billet

I’m happy to split out the first part of the text into First\_Name and whatever is left into Last\_Name.

---

<div class="post-metadata">

**Author:** ![imriskal](https://avatars.discourse-cdn.com/v4/letter/i/b38774/32.png) [@imriskal](https://forum.cloverdx.com/u/imriskal)\
**Post date:** [July 10, 2014, 8:17am UTC](https://forum.cloverdx.com/t/splitting-a-field-containing-peoples-names/1453/2 "2014-07-10T08:17:36Z")

</div>

Hi Kevin,

Here is my very simplified solution. I just assumed that the last space in a string is the delimiter. Everything before is the first name and everything after is the last name.

```auto
$out.0.first_name = substring($in.0.full_name, 0, lastIndexOf($in.0.full_name, " "));
$out.0.last_name = substring($in.0.full_name, lastIndexOf($in.0.full_name, " ")+1);

```

However, I admit this is not a universally valid rule. If you have more complex definitions of first names and last names, you may find useful also split function. For instance:

```auto
string[] names = split($in.0.full_name, " ");
$out.0.first_name = names[0];
$out.0.middle_name = names[1];
$out.0.flast_name = names[2];

```

Regards,
