<?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 use regex to extract just the ID inside of the brackets? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-extract-just-the-ID-inside-of-the-brackets/m-p/424299#M121671</link>
    <description>&lt;P&gt;I will update the question to use the 1010 button my apologies.  &lt;/P&gt;

&lt;P&gt;Yes the URGP_0 is a field that was extracted from it. &lt;/P&gt;</description>
    <pubDate>Wed, 22 Aug 2018 21:27:30 GMT</pubDate>
    <dc:creator>thefuzz4</dc:creator>
    <dc:date>2018-08-22T21:27:30Z</dc:date>
    <item>
      <title>How to use regex to extract just the ID inside of the brackets?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-extract-just-the-ID-inside-of-the-brackets/m-p/424296#M121668</link>
      <description>&lt;P&gt;So I have this data&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; Aug 22 09:13:46 someservername  &amp;lt;118&amp;gt;1 2018-08-22T09:13:46.743+00:00 ip.address LOGSTASH - - - {"timestamp":1534929226738,"process_id":62,"source":"OpsCodi:0","event_type":"SECURITY_MGMT_REGISTRY","data2":{"srctype":"ops_console"},"user":"U654321","target":"some.server.of.ours","message":"Add User [U123456] ","log_level":"INFO"}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I don't have a way to modify the field extractions or anything so I'm at the mercy of splunk.  No admin rights so I've been working on some serious splunk fu with my search.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=index sourcetype=sourcetype  source="source//*.log" | multikv | mvexpand _raw | search URGP_0="User [*]*" | regex URGP_0=(\[(\w+)\]) |  table URGP_0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So all I want to see is just U123456 and I intend to pipe this into a table in my dashboard once I have the regex working properly.  &lt;/P&gt;

&lt;P&gt;I am no master with regex but I've plugged it into various checkers online and they all show that it should be working but splunk just continues to show me the full field value which looks like this &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;User [U123456] ","log_level":"INFO"}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Yes its a terrible field but well prior to me putting in the mvexpand there were no fields detected so now I at least have something to work with. &lt;/P&gt;

&lt;P&gt;Also if possible how to extract this user info from it as well&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; "user":"U654321"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thank you for your help with this. &lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2018 21:04:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-extract-just-the-ID-inside-of-the-brackets/m-p/424296#M121668</guid>
      <dc:creator>thefuzz4</dc:creator>
      <dc:date>2018-08-22T21:04:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to use regex to extract just the ID inside of the brackets?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-extract-just-the-ID-inside-of-the-brackets/m-p/424297#M121669</link>
      <description>&lt;P&gt;Hi @thefuzz4,&lt;/P&gt;

&lt;P&gt;you have to escape &lt;CODE&gt;[ ]&lt;/CODE&gt; characters properly.&lt;BR /&gt;
Also you are not using the right command.&lt;/P&gt;

&lt;P&gt;Something like this should work. &lt;BR /&gt;
&lt;CODE&gt;| rex field=_raw "Add\s*User\s*\[(?&amp;lt;user&amp;gt;[^\]]+)\]"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;or if you already have a field that contains the value&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| rex field=URGP_0 "\[(?&amp;lt;user&amp;gt;[^\]]+)\]"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;EDIT:&lt;BR /&gt;
Changes since your recent edit&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| rex field=_raw "\"user\":\"(?&amp;lt;userinfo&amp;gt;[^\"]+)\""&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;should extract the &lt;STRONG&gt;U654321&lt;/STRONG&gt; value inside of the &lt;STRONG&gt;userinfo&lt;/STRONG&gt; field&lt;/P&gt;

&lt;P&gt;Second EDIT:&lt;/P&gt;

&lt;P&gt;Userinfo:&lt;BR /&gt;
&lt;CODE&gt;| rex field=_raw "(?&amp;lt;userinfo&amp;gt;\"user\":\"[^\"]+\")"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;should extract the &lt;STRONG&gt;"user":"U654321"&lt;/STRONG&gt; into the field &lt;STRONG&gt;userinfo&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2018 21:12:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-extract-just-the-ID-inside-of-the-brackets/m-p/424297#M121669</guid>
      <dc:creator>horsefez</dc:creator>
      <dc:date>2018-08-22T21:12:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to use regex to extract just the ID inside of the brackets?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-extract-just-the-ID-inside-of-the-brackets/m-p/424298#M121670</link>
      <description>&lt;P&gt;Is the field &lt;CODE&gt;URGP_0&lt;/CODE&gt; a field that is extracted already? I don't see that you are creating it anywhere in your data, and it isn't a KV pair, so it looks like your &lt;CODE&gt;search&lt;/CODE&gt; is looking for a field called &lt;CODE&gt;URGP_0&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;It also appears that your data is not complete. You may want to update the question to use the &lt;CODE&gt;101010&lt;/CODE&gt; button to mark the text instead of the &lt;CODE&gt;"&lt;/CODE&gt; button so that is does it as code instead of a quote.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2018 21:17:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-extract-just-the-ID-inside-of-the-brackets/m-p/424298#M121670</guid>
      <dc:creator>cpetterborg</dc:creator>
      <dc:date>2018-08-22T21:17:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to use regex to extract just the ID inside of the brackets?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-extract-just-the-ID-inside-of-the-brackets/m-p/424299#M121671</link>
      <description>&lt;P&gt;I will update the question to use the 1010 button my apologies.  &lt;/P&gt;

&lt;P&gt;Yes the URGP_0 is a field that was extracted from it. &lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2018 21:27:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-extract-just-the-ID-inside-of-the-brackets/m-p/424299#M121671</guid>
      <dc:creator>thefuzz4</dc:creator>
      <dc:date>2018-08-22T21:27:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to use regex to extract just the ID inside of the brackets?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-extract-just-the-ID-inside-of-the-brackets/m-p/424300#M121672</link>
      <description>&lt;P&gt;Thank you that worked like a charm.  I also posted a 2nd question in here and of course after I posted it I saw the answer to my 1st part.  Don't suppose you have some regex fu for that piece? &lt;BR /&gt;
By the way yes I did already have the field for the 1st part so I was able to use the bit about the field.  &lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2018 21:32:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-extract-just-the-ID-inside-of-the-brackets/m-p/424300#M121672</guid>
      <dc:creator>thefuzz4</dc:creator>
      <dc:date>2018-08-22T21:32:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to use regex to extract just the ID inside of the brackets?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-extract-just-the-ID-inside-of-the-brackets/m-p/424301#M121673</link>
      <description>&lt;P&gt;Looks at my edits &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2018 21:35:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-extract-just-the-ID-inside-of-the-brackets/m-p/424301#M121673</guid>
      <dc:creator>horsefez</dc:creator>
      <dc:date>2018-08-22T21:35:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to use regex to extract just the ID inside of the brackets?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-extract-just-the-ID-inside-of-the-brackets/m-p/424302#M121674</link>
      <description>&lt;P&gt;Sorry meant to be like just the U654321 part&lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2018 21:37:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-extract-just-the-ID-inside-of-the-brackets/m-p/424302#M121674</guid>
      <dc:creator>thefuzz4</dc:creator>
      <dc:date>2018-08-22T21:37:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to use regex to extract just the ID inside of the brackets?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-extract-just-the-ID-inside-of-the-brackets/m-p/424303#M121675</link>
      <description>&lt;P&gt;@thefuzz4,&lt;/P&gt;

&lt;P&gt;no problem. My first edit should give you the right solution. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Changes since your recent edit&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| rex field=_raw "\"user\":\"(?&amp;lt;userinfo&amp;gt;[^\"]+)\""&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;should extract the &lt;STRONG&gt;U654321&lt;/STRONG&gt; value inside of the &lt;STRONG&gt;userinfo&lt;/STRONG&gt; field&lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2018 21:39:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-extract-just-the-ID-inside-of-the-brackets/m-p/424303#M121675</guid>
      <dc:creator>horsefez</dc:creator>
      <dc:date>2018-08-22T21:39:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to use regex to extract just the ID inside of the brackets?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-extract-just-the-ID-inside-of-the-brackets/m-p/424304#M121676</link>
      <description>&lt;P&gt;You rock thank you so much&lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2018 21:40:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-extract-just-the-ID-inside-of-the-brackets/m-p/424304#M121676</guid>
      <dc:creator>thefuzz4</dc:creator>
      <dc:date>2018-08-22T21:40:11Z</dc:date>
    </item>
  </channel>
</rss>

