<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Arcade Split Function: Split a name into first and last variables in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/arcade-split-function-split-a-name-into-first-and/m-p/1344446#M55554</link>
    <description>&lt;P&gt;&lt;STRONG&gt;Split&lt;/STRONG&gt; outputs an array, with each item in its own index in the array. So for your example, &lt;STRONG&gt;Split('Jane Doe', ' ') &lt;/STRONG&gt;will output&lt;/P&gt;&lt;PRE&gt;['Jane', 'Doe']&lt;/PRE&gt;&lt;P&gt;Individual elements can be accessed by their index:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var name_array = Split('full_name_field')

var first_name = name_array[0]
var last_name = name_array[1]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do be aware, this assumes a consistent entry of first name, last name as single words. My wife's maiden name, though, would throw this: "van Loon".&lt;/P&gt;</description>
    <pubDate>Wed, 01 Nov 2023 15:19:06 GMT</pubDate>
    <dc:creator>jcarlson</dc:creator>
    <dc:date>2023-11-01T15:19:06Z</dc:date>
    <item>
      <title>Arcade Split Function: Split a name into first and last variables</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-split-function-split-a-name-into-first-and/m-p/1344435#M55551</link>
      <description>&lt;P&gt;Hello! I am hoping I post this question in the right place. I am wanting to write an arcade script that would split one field collected in Survey123 into a first and last name.&lt;/P&gt;&lt;P&gt;I have attached a flow chart of how I anticipate this to work, my question is how to create variables for each word of the split (before and after the space).&lt;/P&gt;&lt;P&gt;Any help or other solutions are appreciated!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Drawing5 (2).png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/84689i8E93B5BE9D5FC22E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Drawing5 (2).png" alt="Drawing5 (2).png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2023 15:08:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-split-function-split-a-name-into-first-and/m-p/1344435#M55551</guid>
      <dc:creator>leahmaps</dc:creator>
      <dc:date>2023-11-01T15:08:17Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Split Function: Split a name into first and last variables</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-split-function-split-a-name-into-first-and/m-p/1344446#M55554</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Split&lt;/STRONG&gt; outputs an array, with each item in its own index in the array. So for your example, &lt;STRONG&gt;Split('Jane Doe', ' ') &lt;/STRONG&gt;will output&lt;/P&gt;&lt;PRE&gt;['Jane', 'Doe']&lt;/PRE&gt;&lt;P&gt;Individual elements can be accessed by their index:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var name_array = Split('full_name_field')

var first_name = name_array[0]
var last_name = name_array[1]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do be aware, this assumes a consistent entry of first name, last name as single words. My wife's maiden name, though, would throw this: "van Loon".&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2023 15:19:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-split-function-split-a-name-into-first-and/m-p/1344446#M55554</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2023-11-01T15:19:06Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Split Function: Split a name into first and last variables</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-split-function-split-a-name-into-first-and/m-p/1344452#M55556</link>
      <description>&lt;P&gt;Thank you! This is super helpful. For my current need, I only need to get the first name, so I am not too concerned about splitting any last names into two.&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, for future knowledge, it looks like the limit parameter might be able to stop a last name from splitting. In case you wanted to keep a last name with a space together, could the code look like this and still split on the first instance of a space?&lt;/P&gt;&lt;LI-CODE lang="python"&gt;var name_array = Split('full_name_field', ' ', 1)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2023 15:26:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-split-function-split-a-name-into-first-and/m-p/1344452#M55556</guid>
      <dc:creator>leahmaps</dc:creator>
      <dc:date>2023-11-01T15:26:30Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Split Function: Split a name into first and last variables</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-split-function-split-a-name-into-first-and/m-p/1344453#M55557</link>
      <description>&lt;P&gt;The output is an array of strings. Here's how to safely extract that data assuming arbitrary input:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var tokens = Split("Your Data", " ");
var count = Count(tokens);
var first = null;
var last = null;
if (count == 1) {
  first = tokens[0];
} else if (count == 2) {
  first = tokens[0];
  last = tokens[1];
} else if (count &amp;gt; 2) {
  var first_array = [];
  for (var i in tokens) {
    if (i == count - 1) {
      break;
    }
    Push(first_array, tokens[i]);
  }
  first = Concatenate(first_array, " ");
  last = tokens[-1];
}
// Do what you need with first and last&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 01 Nov 2023 15:29:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-split-function-split-a-name-into-first-and/m-p/1344453#M55557</guid>
      <dc:creator>DavidSolari</dc:creator>
      <dc:date>2023-11-01T15:29:21Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Split Function: Split a name into first and last variables</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-split-function-split-a-name-into-first-and/m-p/1344454#M55558</link>
      <description>&lt;P&gt;True, but suppose someone had a space in their &lt;EM&gt;first name&lt;/EM&gt;? But yes, the limit parameter can be used that way.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2023 15:32:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-split-function-split-a-name-into-first-and/m-p/1344454#M55558</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2023-11-01T15:32:13Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Split Function: Split a name into first and last variables</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-split-function-split-a-name-into-first-and/m-p/1344456#M55560</link>
      <description>&lt;P&gt;Ah, looks like I was beaten to the punch! As Josh pointed out, names with more than 1 space in them will lead to issues. My code dumps everything but the last token in the first name slot, with some tweaking you can get everything but the first token in the last name slot.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2023 15:33:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-split-function-split-a-name-into-first-and/m-p/1344456#M55560</guid>
      <dc:creator>DavidSolari</dc:creator>
      <dc:date>2023-11-01T15:33:12Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Split Function: Split a name into first and last variables</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-split-function-split-a-name-into-first-and/m-p/1344463#M55561</link>
      <description>&lt;P&gt;The number limiter means it will only return that many split items, so that would return just the first name in the array.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="split.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/84696iDCF4F538DC623E70/image-size/medium?v=v2&amp;amp;px=400" role="button" title="split.png" alt="split.png" /&gt;&lt;/span&gt; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2023 15:39:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-split-function-split-a-name-into-first-and/m-p/1344463#M55561</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2023-11-01T15:39:30Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Split Function: Split a name into first and last variables</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-split-function-split-a-name-into-first-and/m-p/1344466#M55562</link>
      <description>&lt;P&gt;Ah! Good to know! I admittedly have never used that parameter.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2023 15:41:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-split-function-split-a-name-into-first-and/m-p/1344466#M55562</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2023-11-01T15:41:48Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Split Function: Split a name into first and last variables</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-split-function-split-a-name-into-first-and/m-p/1344474#M55564</link>
      <description>&lt;P&gt;If the first name is only one word, you can use this to get any last name, regardless of how many words it has.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var test = 'Jane van der Doe'
var firstName = Split(test,' ')[0]
var lastName = Replace(test, firstName + ' ', '')
return lastName + ', ' + firstName&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;which returns "&lt;SPAN class=""&gt;van der Doe, Jane"&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2023 15:51:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-split-function-split-a-name-into-first-and/m-p/1344474#M55564</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2023-11-01T15:51:58Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Split Function: Split a name into first and last variables</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-split-function-split-a-name-into-first-and/m-p/1344493#M55568</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you, everyone, all your contributions are super helpful! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/363906"&gt;@jcarlson&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/4413"&gt;@DavidSolari&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/2839"&gt;@KenBuja&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2023 16:19:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-split-function-split-a-name-into-first-and/m-p/1344493#M55568</guid>
      <dc:creator>leahmaps</dc:creator>
      <dc:date>2023-11-01T16:19:43Z</dc:date>
    </item>
  </channel>
</rss>

