<?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 to edit my &amp;quot;rex&amp;quot; search in order to extract the User ID in my sample data? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-quot-rex-quot-search-in-order-to-extract-the-User/m-p/237918#M70683</link>
    <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/2328i7F4DE75FC4987F2E/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;So it seems to work here for all the examples you provided. Now if you put exactly what I have here in the quotes of the rex command and it still isn't correctly pulling. Then pick out some events that aren't correctly pulling it and add them so I can see whats wrong with the regex.&lt;/P&gt;

&lt;P&gt;This is the tool I use to test my regex out. &lt;A href="https://regex101.com/"&gt;https://regex101.com/&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;EDIT: Note the text highlighted in green is what regex is saying is getting captured by the capture group. And that group is given the name USERID.&lt;/P&gt;</description>
    <pubDate>Fri, 13 Jan 2017 17:59:11 GMT</pubDate>
    <dc:creator>kmccririe_splun</dc:creator>
    <dc:date>2017-01-13T17:59:11Z</dc:date>
    <item>
      <title>How to edit my "rex" search in order to extract the User ID in my sample data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-quot-rex-quot-search-in-order-to-extract-the-User/m-p/237906#M70671</link>
      <description>&lt;P&gt;Another regular expression/rex field extraction question: How do I get USERID between timestamp and '@JavaClient' ?&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;Does USERID always have to begin with &lt;CODE&gt;(?&amp;lt;&lt;/CODE&gt; and end with &lt;CODE&gt;&amp;gt;.*)&lt;/CODE&gt;  ?&lt;/LI&gt;
&lt;LI&gt;What syntax represents all of these to use rex command ?

&lt;UL&gt;
&lt;LI&gt;number, integer, and digit&lt;/LI&gt;
&lt;LI&gt;date time (specific format? )&lt;/LI&gt;
&lt;LI&gt;letter

&lt;UL&gt;
&lt;LI&gt;special characters&lt;/LI&gt;
&lt;/UL&gt;&lt;/LI&gt;
&lt;/UL&gt;&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;Currently, I have it like this but it's not returning XBATCH, and ABCSRV&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=_raw "\.\d\d\d\s(?.*)\@JavaClient\s"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Raw data&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;PSAPPSRV.3204 (770) [2017-01-12T15:00:32.028 XBATCH@JavaClient IntegrationSvc](3) Returning context. ID=XBATCH, Lang=ENG, UStreamId=150032028_3204.770, Token=DU_CS/2017-01-12-09.00.31.708254/XBATCH/ENG/B82gf3Amj/f5Lx/k1J4f6t9RRtI=

PSAPPSRV.3204 (771) [2017-01-12T15:01:02.551 GetCertificate](3) Returning context. ID=SRBTTRAN, Lang=ENG, UStreamId=150102551_3204.771, Token=DU_CS/2017-01-12-09.01.02.708281/SRBTTRAN/ENG/o0fY1oj0zd5Es1vl3xMOnUaB5t0=

PSAPPSRV.3204 (785) [2017-01-12T15:01:05.037 ABCSRV@JavaClient IntegrationSvc](3) Processing WssecIsAuthenticatedUser command.  CtxUser=ABCSRV/ENG, SwUser=XBATCH/+

PSAPPSRV.3204 (785) [2017-01-12T15:01:05.037 ABCSRV@JavaClient IntegrationSvc](3) Processing SwitchUser command.  CtxUser=ABCSRV/ENG, SwUser=DPRBATCH/+, SwConnInfo=-, SwToken=- 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Jan 2017 21:32:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-quot-rex-quot-search-in-order-to-extract-the-User/m-p/237906#M70671</guid>
      <dc:creator>pwongcha</dc:creator>
      <dc:date>2017-01-12T21:32:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my "rex" search in order to extract the User ID in my sample data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-quot-rex-quot-search-in-order-to-extract-the-User/m-p/237907#M70672</link>
      <description>&lt;P&gt;Your regex is correct in matching XBATCH and ABCSRV however for Splunk's rex command you will need to give your extraction a name. That is what the &lt;CODE&gt;&amp;lt;? ... &amp;gt;&lt;/CODE&gt; in the capture group is for. &lt;/P&gt;

&lt;P&gt;Try doing this &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;\.\d\d\d\s(?&amp;lt;USERID&amp;gt;.*)\@JavaClient\s&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;As for regex syntax here is a cheat sheet I regularly reference when writing regex. &lt;A href="https://www.cheatography.com/davechild/cheat-sheets/regular-expressions/"&gt;https://www.cheatography.com/davechild/cheat-sheets/regular-expressions/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jan 2017 21:59:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-quot-rex-quot-search-in-order-to-extract-the-User/m-p/237907#M70672</guid>
      <dc:creator>kmccririe_splun</dc:creator>
      <dc:date>2017-01-12T21:59:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my "rex" search in order to extract the User ID in my sample data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-quot-rex-quot-search-in-order-to-extract-the-User/m-p/237908#M70673</link>
      <description>&lt;P&gt;Thanks, sorry, I missed that tag.&lt;/P&gt;

&lt;P&gt;| rex field=_raw ".\d\d\d\s(?.*)\@JavaClient\s" &lt;/P&gt;

&lt;P&gt;I get the result but some of USERIDs still show up in as "(785) [2017-01-12T15:01:05.037 ABCSRV"&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2017 15:54:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-quot-rex-quot-search-in-order-to-extract-the-User/m-p/237908#M70673</guid>
      <dc:creator>pwongcha</dc:creator>
      <dc:date>2017-01-13T15:54:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my "rex" search in order to extract the User ID in my sample data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-quot-rex-quot-search-in-order-to-extract-the-User/m-p/237909#M70674</link>
      <description>&lt;P&gt;Your regex seems to have changed. The one you posted originally seems like it should work. &lt;BR /&gt;
Use this regex&lt;BR /&gt;
&lt;CODE&gt;\.\d\d\d\s(?&amp;lt;userid&amp;gt;.*)\@JavaClient\s&lt;/CODE&gt;&lt;BR /&gt;
instead of &lt;BR /&gt;
&lt;CODE&gt;.\d\d\d\s(?&amp;lt;userid&amp;gt;.*)\@JavaClient\s&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2017 17:37:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-quot-rex-quot-search-in-order-to-extract-the-User/m-p/237909#M70674</guid>
      <dc:creator>kmccririe_splun</dc:creator>
      <dc:date>2017-01-13T17:37:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my "rex" search in order to extract the User ID in my sample data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-quot-rex-quot-search-in-order-to-extract-the-User/m-p/237910#M70675</link>
      <description>&lt;P&gt;same result...not working either way &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2017 17:43:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-quot-rex-quot-search-in-order-to-extract-the-User/m-p/237910#M70675</guid>
      <dc:creator>pwongcha</dc:creator>
      <dc:date>2017-01-13T17:43:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my "rex" search in order to extract the User ID in my sample data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-quot-rex-quot-search-in-order-to-extract-the-User/m-p/237911#M70676</link>
      <description>&lt;P&gt;was it @ sign that's the issue?  maybe it needs special escape character that is not \&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2017 17:44:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-quot-rex-quot-search-in-order-to-extract-the-User/m-p/237911#M70676</guid>
      <dc:creator>pwongcha</dc:creator>
      <dc:date>2017-01-13T17:44:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my "rex" search in order to extract the User ID in my sample data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-quot-rex-quot-search-in-order-to-extract-the-User/m-p/237912#M70677</link>
      <description>&lt;P&gt;Are some events correctly pulling the user id out? Is it just some events that pull the numbers before?&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2017 17:45:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-quot-rex-quot-search-in-order-to-extract-the-User/m-p/237912#M70677</guid>
      <dc:creator>kmccririe_splun</dc:creator>
      <dc:date>2017-01-13T17:45:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my "rex" search in order to extract the User ID in my sample data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-quot-rex-quot-search-in-order-to-extract-the-User/m-p/237913#M70678</link>
      <description>&lt;P&gt;The @ symbol is not a reserved character for regex so you shouldn't need to escape it.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2017 17:46:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-quot-rex-quot-search-in-order-to-extract-the-User/m-p/237913#M70678</guid>
      <dc:creator>kmccririe_splun</dc:creator>
      <dc:date>2017-01-13T17:46:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my "rex" search in order to extract the User ID in my sample data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-quot-rex-quot-search-in-order-to-extract-the-User/m-p/237914#M70679</link>
      <description>&lt;P&gt;Yes i got 2 results coming out correctly but a lot still in format "(785) [2017-01-12T15:01:05.037 ABCSRV"&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2017 17:47:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-quot-rex-quot-search-in-order-to-extract-the-User/m-p/237914#M70679</guid>
      <dc:creator>pwongcha</dc:creator>
      <dc:date>2017-01-13T17:47:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my "rex" search in order to extract the User ID in my sample data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-quot-rex-quot-search-in-order-to-extract-the-User/m-p/237915#M70680</link>
      <description>&lt;P&gt;Can you post some samples of events that didn't get it correctly pulled? That way I can put those into my regex tester and tweak the regex.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2017 17:48:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-quot-rex-quot-search-in-order-to-extract-the-User/m-p/237915#M70680</guid>
      <dc:creator>kmccririe_splun</dc:creator>
      <dc:date>2017-01-13T17:48:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my "rex" search in order to extract the User ID in my sample data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-quot-rex-quot-search-in-order-to-extract-the-User/m-p/237916#M70681</link>
      <description>&lt;P&gt;Also can you show me exactly the rex command that you are using?&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2017 17:50:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-quot-rex-quot-search-in-order-to-extract-the-User/m-p/237916#M70681</guid>
      <dc:creator>kmccririe_splun</dc:creator>
      <dc:date>2017-01-13T17:50:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my "rex" search in order to extract the User ID in my sample data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-quot-rex-quot-search-in-order-to-extract-the-User/m-p/237917#M70682</link>
      <description>&lt;P&gt;| rex field=_raw ".\d\d\d\s(?.*)@JavaClient\s"&lt;/P&gt;

&lt;P&gt;still not working&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2017 17:50:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-quot-rex-quot-search-in-order-to-extract-the-User/m-p/237917#M70682</guid>
      <dc:creator>pwongcha</dc:creator>
      <dc:date>2017-01-13T17:50:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my "rex" search in order to extract the User ID in my sample data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-quot-rex-quot-search-in-order-to-extract-the-User/m-p/237918#M70683</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/2328i7F4DE75FC4987F2E/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;So it seems to work here for all the examples you provided. Now if you put exactly what I have here in the quotes of the rex command and it still isn't correctly pulling. Then pick out some events that aren't correctly pulling it and add them so I can see whats wrong with the regex.&lt;/P&gt;

&lt;P&gt;This is the tool I use to test my regex out. &lt;A href="https://regex101.com/"&gt;https://regex101.com/&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;EDIT: Note the text highlighted in green is what regex is saying is getting captured by the capture group. And that group is given the name USERID.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2017 17:59:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-quot-rex-quot-search-in-order-to-extract-the-User/m-p/237918#M70683</guid>
      <dc:creator>kmccririe_splun</dc:creator>
      <dc:date>2017-01-13T17:59:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my "rex" search in order to extract the User ID in my sample data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-quot-rex-quot-search-in-order-to-extract-the-User/m-p/237919#M70684</link>
      <description>&lt;P&gt;the link is very useful.  Thank you!&lt;/P&gt;

&lt;P&gt;These are data that don't work out.  I can't upload screenshot because i don't have karma points &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;PSAPPSRV.152 (132) &lt;A href="https://community.splunk.com/3" target="_blank"&gt;2017-01-13T10:28:59.614 DPRBATCH@JavaClient IntegrationSvc&lt;/A&gt; Returning context. ID=DPRBATCH, Lang=ENG, UStreamId=102859614_152.132, Token=DU_CS/2017-01-13-04.28.59.519666/DPRBATCH/ENG/jOYUAqpyw2rafErYxid/+2tm8gY=&lt;BR /&gt;
PSAPPSRV.152 (132) &lt;A href="https://community.splunk.com/3" target="_blank"&gt;2017-01-13T10:28:59.614 DPRBATCH@JavaClient IntegrationSvc&lt;/A&gt; Returning SwitchUser variables. ID=m6c8RnSP6uzj1TlfV3Hmk7iOO7CrHSvcuI47sKsdK9y4jjuwqx0r3LiOO7CrHSvcuI47sKsdK9y4jjuwqx0r3A==, Pswd=+, ConnInfo=-, Lang=-, Token=-&lt;BR /&gt;
PSAPPSRV.592 (9389) &lt;A href="https://community.splunk.com/3" target="_blank"&gt;2017-01-13T11:16:59.969 SAMSGSRV@JavaClient IntegrationSvc&lt;/A&gt; Processing SwitchUser command.  CtxUser=SAMSGSRV/ENG, SwUser=DPRBATCH/+, SwConnInfo=-, SwToken=-&lt;BR /&gt;
PSAPPSRV.592 (9389) &lt;A href="https://community.splunk.com/3" target="_blank"&gt;2017-01-13T11:16:59.969 SAMSGSRV@JavaClient IntegrationSvc&lt;/A&gt; Processing WssecIsAuthenticatedUser command.  CtxUser=SAMSGSRV/ENG, SwUser=DPRBATCH/+&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:22:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-quot-rex-quot-search-in-order-to-extract-the-User/m-p/237919#M70684</guid>
      <dc:creator>pwongcha</dc:creator>
      <dc:date>2020-09-29T12:22:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my "rex" search in order to extract the User ID in my sample data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-quot-rex-quot-search-in-order-to-extract-the-User/m-p/237920#M70685</link>
      <description>&lt;P&gt;I see the problem there is a period followed by three digits earlier on those events... Here is a regex that matches the whole timestamp try this out.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;\[\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}\s(?&amp;lt;userid&amp;gt;.*)\@JavaClient\s&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2017 18:14:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-quot-rex-quot-search-in-order-to-extract-the-User/m-p/237920#M70685</guid>
      <dc:creator>kmccririe_splun</dc:creator>
      <dc:date>2017-01-13T18:14:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my "rex" search in order to extract the User ID in my sample data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-quot-rex-quot-search-in-order-to-extract-the-User/m-p/237921#M70686</link>
      <description>&lt;P&gt;yep! it works thank you!!  But i also try with shorter one \d{2}.\d{3}\s(?.*)@JavaClient\s&lt;/P&gt;

&lt;P&gt;that works too.  which event has "a period followed by three digits"  i only see a period before three digits.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2017 18:18:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-quot-rex-quot-search-in-order-to-extract-the-User/m-p/237921#M70686</guid>
      <dc:creator>pwongcha</dc:creator>
      <dc:date>2017-01-13T18:18:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my "rex" search in order to extract the User ID in my sample data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-quot-rex-quot-search-in-order-to-extract-the-User/m-p/237922#M70687</link>
      <description>&lt;P&gt;That is what I meant. The extra events you sent me had PSAPPSRV.XXX in the beginning that was matching and messing it up. &lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2017 18:49:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-quot-rex-quot-search-in-order-to-extract-the-User/m-p/237922#M70687</guid>
      <dc:creator>kmccririe_splun</dc:creator>
      <dc:date>2017-01-13T18:49:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my "rex" search in order to extract the User ID in my sample data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-quot-rex-quot-search-in-order-to-extract-the-User/m-p/237923#M70688</link>
      <description>&lt;P&gt;I see. Thanks for pointing this out to me.  I didn't know it would go all the way from the beginning of the string at the beginning of the line.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2017 19:46:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-quot-rex-quot-search-in-order-to-extract-the-User/m-p/237923#M70688</guid>
      <dc:creator>pwongcha</dc:creator>
      <dc:date>2017-01-13T19:46:40Z</dc:date>
    </item>
  </channel>
</rss>

