<?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 match and filter by substr? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-and-filter-by-substr/m-p/155917#M43871</link>
    <description>&lt;P&gt;For multiple possibilities you would use the OR command for regex, which is the pipe &lt;CODE&gt;|&lt;/CODE&gt;.  For the first three characters only, use the "starts with" symbol, otherwise known as the carrot &lt;CODE&gt;^&lt;/CODE&gt;. I'm assuming you mean exactly 456 or 789.  &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;|regex lableData="^456|^789"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;To grab just the one that starts with 789, remove the OR.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;|regex lableData="^789"&lt;/CODE&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 19 Feb 2014 17:12:07 GMT</pubDate>
    <dc:creator>lukejadamec</dc:creator>
    <dc:date>2014-02-19T17:12:07Z</dc:date>
    <item>
      <title>How to match and filter by substr?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-and-filter-by-substr/m-p/155912#M43866</link>
      <description>&lt;P&gt;I have a  log  where &lt;/P&gt;

&lt;P&gt;labelData=123-345&lt;/P&gt;

&lt;P&gt;or  &lt;/P&gt;

&lt;P&gt;lableData=123&lt;/P&gt;

&lt;P&gt;How I want to ignore the -345 and just keep the first 3 characters and report on the occurances.  The above would count for two occurrences for labelData=123.&lt;/P&gt;

&lt;P&gt;I can't seem to figure this out using:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source=*//logs/stdout.log class=myClass | fields labelData | eval newStuff=substr(labelData, 1, 43 | stats count by newStuff |  sort count | reverse
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Input Note: labelData could also be  456-789.  Basically, i just want to match/substr the first 3 characters.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Feb 2014 23:29:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-and-filter-by-substr/m-p/155912#M43866</guid>
      <dc:creator>jaj</dc:creator>
      <dc:date>2014-02-18T23:29:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to match and filter by substr?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-and-filter-by-substr/m-p/155913#M43867</link>
      <description>&lt;P&gt;You can try &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;source=*//logs/stdout.log class=myClass | fields labelData |regex lableData="123.*" | stats count by labelData |  sort count | reverse&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;This will give you the full string in the results, but the results will only include values with the substring.&lt;/P&gt;

&lt;P&gt;If you want to create a new field, then use rex.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;source=*//logs/stdout.log class=myClass | fields labelData | rex field=labelData "^(?P&amp;lt;newStuff&amp;gt;123).*" | stats count by newStuff |  sort count | reverse&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Feb 2014 23:57:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-and-filter-by-substr/m-p/155913#M43867</guid>
      <dc:creator>lukejadamec</dc:creator>
      <dc:date>2014-02-18T23:57:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to match and filter by substr?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-and-filter-by-substr/m-p/155914#M43868</link>
      <description>&lt;P&gt;thanks again!&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2014 16:32:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-and-filter-by-substr/m-p/155914#M43868</guid>
      <dc:creator>jaj</dc:creator>
      <dc:date>2014-02-19T16:32:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to match and filter by substr?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-and-filter-by-substr/m-p/155915#M43869</link>
      <description>&lt;P&gt;If you have multiple substrings to capture, then you can do that also.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2014 16:34:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-and-filter-by-substr/m-p/155915#M43869</guid>
      <dc:creator>lukejadamec</dc:creator>
      <dc:date>2014-02-19T16:34:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to match and filter by substr?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-and-filter-by-substr/m-p/155916#M43870</link>
      <description>&lt;P&gt;QQ: what if the input was 456-789 or 789-012?  how could I use a regex to extract the first three characters only?&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2014 16:56:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-and-filter-by-substr/m-p/155916#M43870</guid>
      <dc:creator>jaj</dc:creator>
      <dc:date>2014-02-19T16:56:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to match and filter by substr?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-and-filter-by-substr/m-p/155917#M43871</link>
      <description>&lt;P&gt;For multiple possibilities you would use the OR command for regex, which is the pipe &lt;CODE&gt;|&lt;/CODE&gt;.  For the first three characters only, use the "starts with" symbol, otherwise known as the carrot &lt;CODE&gt;^&lt;/CODE&gt;. I'm assuming you mean exactly 456 or 789.  &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;|regex lableData="^456|^789"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;To grab just the one that starts with 789, remove the OR.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;|regex lableData="^789"&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2014 17:12:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-and-filter-by-substr/m-p/155917#M43871</guid>
      <dc:creator>lukejadamec</dc:creator>
      <dc:date>2014-02-19T17:12:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to match and filter by substr?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-match-and-filter-by-substr/m-p/155918#M43872</link>
      <description>&lt;P&gt;This is a different answer inspired by above question and responses.&lt;/P&gt;

&lt;P&gt;index="indexname" Type="Error"| eval messageInit=substr(Message, 1, 25)| top limit=20 messageInit&lt;/P&gt;</description>
      <pubDate>Thu, 16 Oct 2014 13:52:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-match-and-filter-by-substr/m-p/155918#M43872</guid>
      <dc:creator>aishelm</dc:creator>
      <dc:date>2014-10-16T13:52:27Z</dc:date>
    </item>
  </channel>
</rss>

