<?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: Formatting Log Name with Regex in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Formatting-Log-Name-with-Regex/m-p/210502#M187834</link>
    <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex field=_raw "_\w+_(?&amp;lt;parameterName&amp;gt;\w+)\." | table parameterName
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 03 Aug 2016 14:46:13 GMT</pubDate>
    <dc:creator>sundareshr</dc:creator>
    <dc:date>2016-08-03T14:46:13Z</dc:date>
    <item>
      <title>Formatting Log Name with Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Formatting-Log-Name-with-Regex/m-p/210501#M187833</link>
      <description>&lt;P&gt;Hello. I am currently trying to do something with a list of logs that I have been given.&lt;/P&gt;

&lt;P&gt;All of the logs have the same format:&lt;/P&gt;

&lt;P&gt;/this/is/.../an_example_relevantInformationHere.2016-08-03.log&lt;/P&gt;

&lt;P&gt;What I want to do is to use regex to search through the strings and to find the part that says relevantInformationHere and create a table with that as the header. Right now my rex looks like:&lt;/P&gt;

&lt;P&gt;..|rex "an_example_(?\w+)."| table parameterName&lt;/P&gt;

&lt;P&gt;It looks like it worked in the regex testers that I used, but I am not receiving the expected output in splunk. What am I doing wrong and is there a difference between the splunk regex and the regex on another site?&lt;/P&gt;

&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 10:30:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Formatting-Log-Name-with-Regex/m-p/210501#M187833</guid>
      <dc:creator>JibBgh</dc:creator>
      <dc:date>2020-09-29T10:30:40Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting Log Name with Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Formatting-Log-Name-with-Regex/m-p/210502#M187834</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex field=_raw "_\w+_(?&amp;lt;parameterName&amp;gt;\w+)\." | table parameterName
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 03 Aug 2016 14:46:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Formatting-Log-Name-with-Regex/m-p/210502#M187834</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-08-03T14:46:13Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting Log Name with Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Formatting-Log-Name-with-Regex/m-p/210503#M187835</link>
      <description>&lt;P&gt;When I tried that, it ended up putting the raw string parameterName instead of the actual value it should be.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2016 14:58:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Formatting-Log-Name-with-Regex/m-p/210503#M187835</guid>
      <dc:creator>JibBgh</dc:creator>
      <dc:date>2016-08-03T14:58:46Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting Log Name with Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Formatting-Log-Name-with-Regex/m-p/210504#M187836</link>
      <description>&lt;P&gt;I just test this run anywhere sample and it works. Can you test this and let me know the results&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval x="/this/is/.../an_example_relevantInformationHere.2016-08-03.log" | rex field=x "_\w+_(?&amp;lt;parameterName&amp;gt;\w+)\." | table parameterName
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 03 Aug 2016 15:42:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Formatting-Log-Name-with-Regex/m-p/210504#M187836</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-08-03T15:42:44Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting Log Name with Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Formatting-Log-Name-with-Regex/m-p/210505#M187837</link>
      <description>&lt;P&gt;Assuming you are talking about the source field give this a go:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=source "(?&amp;lt;parameterName&amp;gt;[a-zA-Z]+)\.\d{4}-\d{2}-\d{2}\.\w+"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Keep in mind you can play with the following bit [a-zA-Z]+ to accept whatever symbols you might expect in your relevant information section. Also remember \w+ includes underscores.&lt;/P&gt;

&lt;P&gt;Hope that helps&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2016 15:46:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Formatting-Log-Name-with-Regex/m-p/210505#M187837</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2016-08-03T15:46:37Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting Log Name with Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Formatting-Log-Name-with-Regex/m-p/210506#M187838</link>
      <description>&lt;P&gt;That worked properly, however, will this work properly without hard coding the name?&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2016 18:30:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Formatting-Log-Name-with-Regex/m-p/210506#M187838</guid>
      <dc:creator>JibBgh</dc:creator>
      <dc:date>2016-08-03T18:30:08Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting Log Name with Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Formatting-Log-Name-with-Regex/m-p/210507#M187839</link>
      <description>&lt;P&gt;Is the name of the file. As in the source? If it is, change the rex command to this and it should work&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex field=source "_\w+_(?&amp;lt;parameterName&amp;gt;\w+)\." 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 03 Aug 2016 18:38:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Formatting-Log-Name-with-Regex/m-p/210507#M187839</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-08-03T18:38:22Z</dc:date>
    </item>
  </channel>
</rss>

