<?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 How to write regex to extract one capture group for user ID? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-to-extract-one-capture-group-for-user-ID/m-p/126533#M34266</link>
    <description>&lt;P&gt;I have a regex question that I hope will be easy for someone.  I’m not big on regexes so I’m coming to you all for help.  I have events where the user account is coming in by itself (xyz123) and sometimes with the domain (domain\xyz123), see below.  I was able to just pull out the user IDs with a regex, but it had two capture groups instead of just one &lt;CODE&gt;[U|u]ser\s(?:[\w\.]+\\(\w+)|([\w]+))\s&lt;/CODE&gt;.  I’d like to have one capture group that only has the user ID.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[MsgID: 2]The user domain\xyz123 with source IP address

[MsgID: 2]The user xyz123 with source IP address
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 16 Sep 2014 12:17:04 GMT</pubDate>
    <dc:creator>kmcconnell</dc:creator>
    <dc:date>2014-09-16T12:17:04Z</dc:date>
    <item>
      <title>How to write regex to extract one capture group for user ID?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-to-extract-one-capture-group-for-user-ID/m-p/126533#M34266</link>
      <description>&lt;P&gt;I have a regex question that I hope will be easy for someone.  I’m not big on regexes so I’m coming to you all for help.  I have events where the user account is coming in by itself (xyz123) and sometimes with the domain (domain\xyz123), see below.  I was able to just pull out the user IDs with a regex, but it had two capture groups instead of just one &lt;CODE&gt;[U|u]ser\s(?:[\w\.]+\\(\w+)|([\w]+))\s&lt;/CODE&gt;.  I’d like to have one capture group that only has the user ID.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[MsgID: 2]The user domain\xyz123 with source IP address

[MsgID: 2]The user xyz123 with source IP address
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Sep 2014 12:17:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-to-extract-one-capture-group-for-user-ID/m-p/126533#M34266</guid>
      <dc:creator>kmcconnell</dc:creator>
      <dc:date>2014-09-16T12:17:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to write regex to extract one capture group for user ID?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-to-extract-one-capture-group-for-user-ID/m-p/126534#M34267</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[uU]ser\s(?:[\w.]+\\)?(?&amp;lt;user&amp;gt;\w+)\s
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;...provided I correctly understand your problem &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Sep 2014 12:28:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-to-extract-one-capture-group-for-user-ID/m-p/126534#M34267</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-09-16T12:28:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to write regex to extract one capture group for user ID?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-to-extract-one-capture-group-for-user-ID/m-p/126535#M34268</link>
      <description>&lt;P&gt;Hi kmcconnel,&lt;/P&gt;

&lt;P&gt;assuming your ID's are always 6 alphanumeric values and are always before &lt;CODE&gt;with&lt;/CODE&gt; in the events, try this regex:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?&amp;lt;myUserID&amp;gt;\w{6})(?=\swith)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;hope this helps ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Tue, 16 Sep 2014 12:30:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-to-extract-one-capture-group-for-user-ID/m-p/126535#M34268</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2014-09-16T12:30:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to write regex to extract one capture group for user ID?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-to-extract-one-capture-group-for-user-ID/m-p/126536#M34269</link>
      <description>&lt;P&gt;HeHe, too slow again....&lt;/P&gt;</description>
      <pubDate>Tue, 16 Sep 2014 12:31:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-to-extract-one-capture-group-for-user-ID/m-p/126536#M34269</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2014-09-16T12:31:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to write regex to extract one capture group for user ID?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-to-extract-one-capture-group-for-user-ID/m-p/126537#M34270</link>
      <description>&lt;P&gt;This works fine after added additional backslash after &lt;CODE&gt;[\w.]+&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Sep 2014 22:17:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-to-extract-one-capture-group-for-user-ID/m-p/126537#M34270</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-09-16T22:17:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to write regex to extract one capture group for user ID?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-to-extract-one-capture-group-for-user-ID/m-p/126538#M34271</link>
      <description>&lt;P&gt;I tried both approaches and they both work, but the answer from martin_mueller was what I had been working toward.  Thank you both for the help.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Sep 2014 17:41:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-to-extract-one-capture-group-for-user-ID/m-p/126538#M34271</guid>
      <dc:creator>kmcconnell</dc:creator>
      <dc:date>2014-09-17T17:41:38Z</dc:date>
    </item>
  </channel>
</rss>

