<?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: How could I extract a user ID using regex? in All Apps and Add-ons</title>
    <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-could-I-extract-a-user-ID-using-regex/m-p/139274#M11875</link>
    <description>&lt;P&gt;I wrote the interactive field extractor.  It wasn't optimized to get the case where you want some alphanumeric characters that are touching other alphanumeric characters.&lt;/P&gt;

&lt;P&gt;But the solution is simple.&lt;/P&gt;

&lt;P&gt;Just go back into interactive field extractor, have it generate the regex:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?i)^(?:[^/]*/){4}\d+\)\s+(?P&amp;lt;FIELDNAME&amp;gt;[^ ]+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then click "edit" and change the last "+" to a "{4}"&lt;/P&gt;</description>
    <pubDate>Fri, 07 Feb 2014 20:55:25 GMT</pubDate>
    <dc:creator>carasso</dc:creator>
    <dc:date>2014-02-07T20:55:25Z</dc:date>
    <item>
      <title>How could I extract a user ID using regex?</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-could-I-extract-a-user-ID-using-regex/m-p/139271#M11872</link>
      <description>&lt;P&gt;I have log data that contains userID and have not been able to extract the first few characters of the string.&lt;/P&gt;

&lt;P&gt;Sample strings:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; (G477EFK@XYZ.LOCAL)
 (H587ABF@XYZ.LOCAL)
 (7P4LCDK@XYZ.LOCAL)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I only want the first four alphanumeric characters.&lt;BR /&gt;
When I tried the interactive field extracter I can only get it to extract the full string usin it's suggested regex of:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; (?i)^(?:[^/]*/){4}\d+\)\s+(?P&amp;lt;FIELDNAME&amp;gt;[^ ]+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I've tested this one with a regex tester online and it works for what I need but cant get it to work with Splunk.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[^(XYZ.local)](?:[a-z0-9]){4}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any suggestions?&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2014 21:42:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-could-I-extract-a-user-ID-using-regex/m-p/139271#M11872</guid>
      <dc:creator>digital_alchemy</dc:creator>
      <dc:date>2014-02-05T21:42:11Z</dc:date>
    </item>
    <item>
      <title>Re: How could I extract a user ID using regex?</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-could-I-extract-a-user-ID-using-regex/m-p/139272#M11873</link>
      <description>&lt;P&gt;through &lt;CODE&gt;rex&lt;/CODE&gt;;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex "\((?&amp;lt;your_field&amp;gt;\w{4})[^@]+@\w+\.\w+\)" | the rest of your search
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;/k&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2014 21:55:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-could-I-extract-a-user-ID-using-regex/m-p/139272#M11873</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2014-02-05T21:55:12Z</dc:date>
    </item>
    <item>
      <title>Re: How could I extract a user ID using regex?</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-could-I-extract-a-user-ID-using-regex/m-p/139273#M11874</link>
      <description>&lt;P&gt;This might be oversimplifying things a bit, but if you only want the first 4 alpha-numeric characters after the opening parentheses, would this do the job for you?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|rex field=_raw "\((?&amp;lt;first_4_char&amp;gt;\w{4})"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you want to put the extraction in to your &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.0.1/admin/Propsconf"&gt;props.conf&lt;/A&gt; file (similar to how the interactive field extractor saves this) its simply:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[StanzaName]
EXTRACT-myExtract=\((?&amp;lt;first_4_char&amp;gt;\w{4})
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;After adding this line to your props.conf file, you an issue the following search command to reload the extractions:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| extract reload=T
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Feb 2014 09:38:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-could-I-extract-a-user-ID-using-regex/m-p/139273#M11874</guid>
      <dc:creator>Rob</dc:creator>
      <dc:date>2014-02-06T09:38:53Z</dc:date>
    </item>
    <item>
      <title>Re: How could I extract a user ID using regex?</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-could-I-extract-a-user-ID-using-regex/m-p/139274#M11875</link>
      <description>&lt;P&gt;I wrote the interactive field extractor.  It wasn't optimized to get the case where you want some alphanumeric characters that are touching other alphanumeric characters.&lt;/P&gt;

&lt;P&gt;But the solution is simple.&lt;/P&gt;

&lt;P&gt;Just go back into interactive field extractor, have it generate the regex:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?i)^(?:[^/]*/){4}\d+\)\s+(?P&amp;lt;FIELDNAME&amp;gt;[^ ]+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then click "edit" and change the last "+" to a "{4}"&lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2014 20:55:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-could-I-extract-a-user-ID-using-regex/m-p/139274#M11875</guid>
      <dc:creator>carasso</dc:creator>
      <dc:date>2014-02-07T20:55:25Z</dc:date>
    </item>
  </channel>
</rss>

