<?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 help with regular expression to extract first and last names in csv in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/help-with-regular-expression-to-extract-first-and-last-names-in/m-p/175665#M35263</link>
    <description>&lt;P&gt;Hi.&lt;BR /&gt;
I have a csv file that looks like:&lt;/P&gt;

&lt;P&gt;123,"firstname secondname","firstlast secondlast",&lt;BR /&gt;
124,firstname secondname, firstlast secondlast,&lt;BR /&gt;
125,"firstname","firstlast",&lt;BR /&gt;
126,firstname,firstlast,&lt;/P&gt;

&lt;P&gt;I need to extract the fields (firstnames and lastnames) (doesn't matter if has one/two names/lasts or if has quotation marks), how i can?&lt;BR /&gt;
My regular expressions only catch with quotation marks, or without or only two words in the first names, but not all.&lt;/P&gt;

&lt;P&gt;Thanks for the help&lt;/P&gt;</description>
    <pubDate>Fri, 08 May 2015 18:55:08 GMT</pubDate>
    <dc:creator>changux</dc:creator>
    <dc:date>2015-05-08T18:55:08Z</dc:date>
    <item>
      <title>help with regular expression to extract first and last names in csv</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/help-with-regular-expression-to-extract-first-and-last-names-in/m-p/175665#M35263</link>
      <description>&lt;P&gt;Hi.&lt;BR /&gt;
I have a csv file that looks like:&lt;/P&gt;

&lt;P&gt;123,"firstname secondname","firstlast secondlast",&lt;BR /&gt;
124,firstname secondname, firstlast secondlast,&lt;BR /&gt;
125,"firstname","firstlast",&lt;BR /&gt;
126,firstname,firstlast,&lt;/P&gt;

&lt;P&gt;I need to extract the fields (firstnames and lastnames) (doesn't matter if has one/two names/lasts or if has quotation marks), how i can?&lt;BR /&gt;
My regular expressions only catch with quotation marks, or without or only two words in the first names, but not all.&lt;/P&gt;

&lt;P&gt;Thanks for the help&lt;/P&gt;</description>
      <pubDate>Fri, 08 May 2015 18:55:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/help-with-regular-expression-to-extract-first-and-last-names-in/m-p/175665#M35263</guid>
      <dc:creator>changux</dc:creator>
      <dc:date>2015-05-08T18:55:08Z</dc:date>
    </item>
    <item>
      <title>Re: help with regular expression to extract first and last names in csv</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/help-with-regular-expression-to-extract-first-and-last-names-in/m-p/175666#M35264</link>
      <description>&lt;P&gt;what's the regex you used?&lt;/P&gt;</description>
      <pubDate>Sat, 09 May 2015 00:03:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/help-with-regular-expression-to-extract-first-and-last-names-in/m-p/175666#M35264</guid>
      <dc:creator>sk314</dc:creator>
      <dc:date>2015-05-09T00:03:44Z</dc:date>
    </item>
    <item>
      <title>Re: help with regular expression to extract first and last names in csv</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/help-with-regular-expression-to-extract-first-and-last-names-in/m-p/175667#M35265</link>
      <description>&lt;P&gt;Do you want to extract the firstname and secondname into separate fields or would you be good with just grabbing the name between the quotation marks?&lt;/P&gt;

&lt;P&gt;maybe this would work for you?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;\d+,\"(?&amp;lt;firstname&amp;gt;[A-Za-z\sA-Za-z]+)\",\"(?&amp;lt;lastname&amp;gt;[A-Za-z\sA-Za-z]+)\"\,
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;otherwise you can write one that has optional matches to extract the secondname as it own field&lt;/P&gt;

&lt;P&gt;a good site to play at is - &lt;A href="https://regex101.com/"&gt;https://regex101.com/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Sep 2015 03:36:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/help-with-regular-expression-to-extract-first-and-last-names-in/m-p/175667#M35265</guid>
      <dc:creator>jgbricker</dc:creator>
      <dc:date>2015-09-18T03:36:27Z</dc:date>
    </item>
    <item>
      <title>Re: help with regular expression to extract first and last names in csv</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/help-with-regular-expression-to-extract-first-and-last-names-in/m-p/175668#M35266</link>
      <description>&lt;P&gt;This should get the separate names:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;\d+,\"(?&amp;lt;firstname&amp;gt;[A-Za-z]+)(\s)?(?&amp;lt;secondname&amp;gt;[A-Za-z]+)?\",\"(?&amp;lt;lastname&amp;gt;[A-Za-z]+)(\s)?(?&amp;lt;secondlast&amp;gt;[A-Za-z]+)?\",
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can tweak as needed. The ? works as an optional match after the optional criteria. Also you can use curly braces and a range. check out this - &lt;A href="http://www.regular-expressions.info/optional.html"&gt;http://www.regular-expressions.info/optional.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Sep 2015 04:10:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/help-with-regular-expression-to-extract-first-and-last-names-in/m-p/175668#M35266</guid>
      <dc:creator>jgbricker</dc:creator>
      <dc:date>2015-09-18T04:10:49Z</dc:date>
    </item>
    <item>
      <title>Re: help with regular expression to extract first and last names in csv</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/help-with-regular-expression-to-extract-first-and-last-names-in/m-p/175669#M35267</link>
      <description>&lt;P&gt;If you just add a header line to the CSV file, using &lt;CODE&gt;inputcsv&lt;/CODE&gt;, etc. will automatically create the field and you will not need to do anything.  How are you bringing in this into Splunk?&lt;/P&gt;</description>
      <pubDate>Fri, 18 Sep 2015 04:33:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/help-with-regular-expression-to-extract-first-and-last-names-in/m-p/175669#M35267</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-09-18T04:33:21Z</dc:date>
    </item>
    <item>
      <title>Re: help with regular expression to extract first and last names in csv</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/help-with-regular-expression-to-extract-first-and-last-names-in/m-p/175670#M35268</link>
      <description>&lt;P&gt;this should do the trick&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?&amp;lt;number&amp;gt;[^,]+)(?:\,\"|\,)(?&amp;lt;first&amp;gt;[^",]+)(?:\"\,\"|\,)(?&amp;lt;last&amp;gt;[^,"]+)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 18 Sep 2015 07:01:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/help-with-regular-expression-to-extract-first-and-last-names-in/m-p/175670#M35268</guid>
      <dc:creator>aholzel</dc:creator>
      <dc:date>2015-09-18T07:01:36Z</dc:date>
    </item>
    <item>
      <title>Re: help with regular expression to extract first and last names in csv</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/help-with-regular-expression-to-extract-first-and-last-names-in/m-p/175671#M35269</link>
      <description>&lt;P&gt;yeah it's look pretty good&lt;/P&gt;</description>
      <pubDate>Fri, 18 Sep 2015 08:59:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/help-with-regular-expression-to-extract-first-and-last-names-in/m-p/175671#M35269</guid>
      <dc:creator>ddarmand</dc:creator>
      <dc:date>2015-09-18T08:59:19Z</dc:date>
    </item>
  </channel>
</rss>

