<?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: Help In writing Regex for a dashboard in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Help-In-writing-Regex-for-a-dashboard/m-p/421400#M45375</link>
    <description>&lt;P&gt;Greetings @mayank101,&lt;/P&gt;

&lt;P&gt;Assuming your data is in one line as you typed it and you want everything after and including CMD until the next space removed, you can trim it as such:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval _raw="1 LOG-NOTIFYCMD-dce- LOG-NOTIFYCMD-dce 2 LOG-NOTIFYCMD-abc-LOG-NOTIFYCMD-abc 3 LOG-NOTIFYCMD-As1-LOG-NOTIFYCMD-As1"
| eval _raw = replace(_raw, "CMD[^ ]+", "")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 01 Aug 2019 19:16:04 GMT</pubDate>
    <dc:creator>jacobpevans</dc:creator>
    <dc:date>2019-08-01T19:16:04Z</dc:date>
    <item>
      <title>Help In writing Regex for a dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Help-In-writing-Regex-for-a-dashboard/m-p/421397#M45372</link>
      <description>&lt;P&gt;I have may entries under the event field. I wanted a regex that separates extra out such as anything after GBP ,AMP &lt;BR /&gt;
Eg -                                  events&lt;BR /&gt;&lt;BR /&gt;
  1    LOG-NOTIFYCMD-dce-&amp;lt;1SS4C413----&amp;gt; LOG-NOTIFYCMD-dce&lt;BR /&gt;
  2   LOG-NOTIFYCMD-abc-&amp;lt;1SS4C413----&amp;gt;LOG-NOTIFYCMD-abc&lt;BR /&gt;
  3   LOG-NOTIFYCMD-As1-&amp;lt;1SS4C413----&amp;gt;LOG-NOTIFYCMD-As1&lt;BR /&gt;
        .&lt;BR /&gt;
        .&lt;BR /&gt;
        .&lt;/P&gt;

&lt;P&gt;Can you help me writing regex ,I am stuck in it.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Aug 2019 18:00:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Help-In-writing-Regex-for-a-dashboard/m-p/421397#M45372</guid>
      <dc:creator>mayank101</dc:creator>
      <dc:date>2019-08-01T18:00:24Z</dc:date>
    </item>
    <item>
      <title>Re: Help In writing Regex for a dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Help-In-writing-Regex-for-a-dashboard/m-p/421398#M45373</link>
      <description>&lt;P&gt;@mayank101 for the community to assist you better please add more details as to what you need to extract in the above event. Also what is the pattern before and after the text that you want to extract.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Aug 2019 19:05:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Help-In-writing-Regex-for-a-dashboard/m-p/421398#M45373</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2019-08-01T19:05:11Z</dc:date>
    </item>
    <item>
      <title>Re: Help In writing Regex for a dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Help-In-writing-Regex-for-a-dashboard/m-p/421399#M45374</link>
      <description>&lt;P&gt;As I have mentioned in example....anything after CMD needs to be eliminated. And the pattern is that CMD is the last word in expression and they start with LOG.I have already given example to make it more clear.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Aug 2019 19:10:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Help-In-writing-Regex-for-a-dashboard/m-p/421399#M45374</guid>
      <dc:creator>mayank101</dc:creator>
      <dc:date>2019-08-01T19:10:05Z</dc:date>
    </item>
    <item>
      <title>Re: Help In writing Regex for a dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Help-In-writing-Regex-for-a-dashboard/m-p/421400#M45375</link>
      <description>&lt;P&gt;Greetings @mayank101,&lt;/P&gt;

&lt;P&gt;Assuming your data is in one line as you typed it and you want everything after and including CMD until the next space removed, you can trim it as such:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval _raw="1 LOG-NOTIFYCMD-dce- LOG-NOTIFYCMD-dce 2 LOG-NOTIFYCMD-abc-LOG-NOTIFYCMD-abc 3 LOG-NOTIFYCMD-As1-LOG-NOTIFYCMD-As1"
| eval _raw = replace(_raw, "CMD[^ ]+", "")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 Aug 2019 19:16:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Help-In-writing-Regex-for-a-dashboard/m-p/421400#M45375</guid>
      <dc:creator>jacobpevans</dc:creator>
      <dc:date>2019-08-01T19:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: Help In writing Regex for a dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Help-In-writing-Regex-for-a-dashboard/m-p/421401#M45376</link>
      <description>&lt;P&gt;We have no idea what you mean.  What is &lt;CODE&gt;GBP&lt;/CODE&gt; (Great British Pound)?  What is &lt;CODE&gt;AMP&lt;/CODE&gt; (ampersand, amperes)?  Why do this strings not appear in your event.  This must be a troll.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Aug 2019 19:16:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Help-In-writing-Regex-for-a-dashboard/m-p/421401#M45376</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-08-01T19:16:45Z</dc:date>
    </item>
    <item>
      <title>Re: Help In writing Regex for a dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Help-In-writing-Regex-for-a-dashboard/m-p/421402#M45377</link>
      <description>&lt;P&gt;@mayank101 well in your question you have mentioned &lt;CODE&gt;GBP&lt;/CODE&gt; and &lt;CODE&gt;AMP&lt;/CODE&gt; which is never present in your sample data. However, even if I assume you wanted to remove anything after CMD, the pattern would be CMD exist before the data to be removed and what should be there after data to be removed is taken out?&lt;/P&gt;

&lt;P&gt;Does the text highlighted in red below need to be removed? Also whether you want to remove them or extract them or anonymize?&lt;/P&gt;

&lt;P&gt;1 LOG-NOTIFYCMD- &lt;CODE&gt;dce&lt;/CODE&gt; - LOG-NOTIFYCMD- &lt;CODE&gt;dce&lt;/CODE&gt; 2 LOG-NOTIFYCMD- &lt;CODE&gt;abc&lt;/CODE&gt; -LOG-NOTIFYCMD- &lt;CODE&gt;abc&lt;/CODE&gt; 3 LOG-NOTIFYCMD- &lt;CODE&gt;As1&lt;/CODE&gt; -LOG-NOTIFYCMD- &lt;CODE&gt;As1&lt;/CODE&gt; &lt;/P&gt;</description>
      <pubDate>Thu, 01 Aug 2019 19:20:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Help-In-writing-Regex-for-a-dashboard/m-p/421402#M45377</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2019-08-01T19:20:29Z</dc:date>
    </item>
    <item>
      <title>Re: Help In writing Regex for a dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Help-In-writing-Regex-for-a-dashboard/m-p/421403#M45378</link>
      <description>&lt;P&gt;I want it to be extracted.Yes you are right it has to be extracted upto CMD.&lt;/P&gt;

&lt;P&gt;Eg: event : LOG-NOTIFYCMD-&lt;CODE&gt;dce&lt;/CODE&gt;- &lt;BR /&gt;
                   LOG-NOTIFYCMD-`abc&lt;/P&gt;

&lt;P&gt;Desired Result to be extracted: LOG-NOTIFYCMD&lt;BR /&gt;
                                                       LOG-NOTIFYCMD&lt;/P&gt;</description>
      <pubDate>Thu, 01 Aug 2019 19:25:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Help-In-writing-Regex-for-a-dashboard/m-p/421403#M45378</guid>
      <dc:creator>mayank101</dc:creator>
      <dc:date>2019-08-01T19:25:34Z</dc:date>
    </item>
    <item>
      <title>Re: Help In writing Regex for a dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Help-In-writing-Regex-for-a-dashboard/m-p/421404#M45379</link>
      <description>&lt;P&gt;Your use of &lt;CODE&gt;extract&lt;/CODE&gt; is VERY unclear.  Show the sample events and a mockup of the desire result.  Then you won't need to use any words at all.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Aug 2019 03:46:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Help-In-writing-Regex-for-a-dashboard/m-p/421404#M45379</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-08-02T03:46:51Z</dc:date>
    </item>
    <item>
      <title>Re: Help In writing Regex for a dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Help-In-writing-Regex-for-a-dashboard/m-p/421405#M45380</link>
      <description>&lt;P&gt;@mayank101  so still not clear. In a single event same text can occur several times and you need to extract all of them? Why? Please add context of what you have in data what you need to do for field extraction and once you have the field extracted how are you going to use it?&lt;/P&gt;

&lt;P&gt;Is LOG_NOTIFYCMD going to be the same across or can it vary in your data, can you add sample?&lt;/P&gt;

&lt;P&gt;Finally do try to understand that regular expression will be tightly coupled with the data you have and pattern in the data. So unless you explain your requirement  correctly with correct data sample (you can definitely anonymize sensitive information so that regular expression does not change) for us to assist you better.&lt;/P&gt;

&lt;P&gt;Following is a run anywhere example based on what you have described so far but I have no idea if this is really what you need and if you do, what would be the right use case for this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|  makeresults
|  eval _raw="1 LOG-NOTIFYCMD- dce - LOG-NOTIFYCMD- dce 2 LOG-NOTIFYCMD- abc -LOG-NOTIFYCMD- abc 3 LOG-NOTIFYCMD- As1 -LOG-NOTIFYCMD- As1"
|  rex "(?&amp;lt;myfield&amp;gt;LOG-NOTIFYCMD)" max_match=0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Following is a more generic regular expression as per your data (with the same disclaimer that it may not work as per your expectations until you provide correct event samples and requirement for field extraction)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|  makeresults
|  eval _raw="1 LOG-NOTIFYCMD- dce - LOG-NOTIFYCMD- dce 2 LOG-NOTIFYCMD- abc -LOG-NOTIFYCMD- abc 3 LOG-NOTIFYCMD- As1 -LOG-NOTIFYCMD- As1"
|  rex "\s*(?&amp;lt;myfield&amp;gt;[^\-]+\-[^\-]+)\-\s[^\s]+" max_match=0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would recommend you to try regex101.com for you to come up with regex extraction and understand the same (&lt;A href="https://regex101.com/r/bJBBg7/1"&gt;try sample of Reg Ex used above&lt;/A&gt;) . Or else use Interactive Field Extraction in Splunk (&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/Knowledge/ExtractfieldsinteractivelywithIFX"&gt;link to Step by Step IFX Splunk Documentation&lt;/A&gt;)  where you let Splunk generate the RegEx based on the sample event and field value you highlight in the event.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Aug 2019 04:42:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Help-In-writing-Regex-for-a-dashboard/m-p/421405#M45380</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2019-08-02T04:42:55Z</dc:date>
    </item>
    <item>
      <title>Re: Help In writing Regex for a dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Help-In-writing-Regex-for-a-dashboard/m-p/421406#M45381</link>
      <description>&lt;P&gt;I apologize woodcock  for being unclear. I will try to be more clear next time.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Aug 2019 15:06:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Help-In-writing-Regex-for-a-dashboard/m-p/421406#M45381</guid>
      <dc:creator>mayank101</dc:creator>
      <dc:date>2019-08-02T15:06:08Z</dc:date>
    </item>
    <item>
      <title>Re: Help In writing Regex for a dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Help-In-writing-Regex-for-a-dashboard/m-p/421407#M45382</link>
      <description>&lt;P&gt;I apologize niketnilay  for being unclear. I will try to be more clear next time.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Aug 2019 15:06:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Help-In-writing-Regex-for-a-dashboard/m-p/421407#M45382</guid>
      <dc:creator>mayank101</dc:creator>
      <dc:date>2019-08-02T15:06:36Z</dc:date>
    </item>
    <item>
      <title>Re: Help In writing Regex for a dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Help-In-writing-Regex-for-a-dashboard/m-p/421408#M45383</link>
      <description>&lt;P&gt;So try again.  show us the raw events and a mockup of your desired final outcome.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Aug 2019 15:32:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Help-In-writing-Regex-for-a-dashboard/m-p/421408#M45383</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-08-02T15:32:10Z</dc:date>
    </item>
  </channel>
</rss>

