<?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: Problem with regular expression in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Problem-with-regular-expression/m-p/110735#M28956</link>
    <description>&lt;P&gt;Is the lookup table write_rules.csv empty? What does it return if you just run this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup write_rules.csv 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 27 Mar 2015 17:12:06 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2015-03-27T17:12:06Z</dc:date>
    <item>
      <title>Problem with regular expression</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Problem-with-regular-expression/m-p/110732#M28953</link>
      <description>&lt;P&gt;Hi everyone, I have create a regular expression query that match in a long list of pathname 1 specific folder, and next cut everything that there is after this folder:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   index=main "  | rex "\s\-\s\[(?&amp;lt;path_dd&amp;gt;.+)\specific_folder" | dedup path_dd | eval path="file:read:"+path_dd+"*" | sort by path| table path | outputlookup output.csv append=True
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Next, I have add inputlookuptable at the start of the query, this table contain always path name, and there is one only field per line: path&lt;/P&gt;

&lt;P&gt;So I have tried to edit the query like that:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | inputlookup write_rules.csv | rex "(?&amp;lt;path_dd&amp;gt;.+)\/specific_folder" | table path_dd
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But it's not working, can anyone help me?&lt;BR /&gt;
Thank you &lt;/P&gt;

&lt;P&gt;Example of the file:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;/home/jenkins/qa-automation-smcconnell/Automation/Tomcats/tomcat7/work/Catalina/localhost/host-manager/loader
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;/home/jenkins/qa-automation-smcconnell/Automation/Tomcats/tomcat7/work/Catalina/localhost/examples/loader&lt;BR /&gt;
   /home/jenkins/qa-automation-smcconnell/Automation/Tomcats/tomcat7/work/Catalina/localhost/xwiki_oracle/loader&lt;BR /&gt;
   /home/jenkins/qa-automation-smcconnell/Automation/Tomcats/tomcat7/work/Catalina/localhost/xwiki_oracle/SESSIONS.ser&lt;BR /&gt;
   /home/jenkins/qa-automation-smcconnell/Automation/Tomcats/tomcat7/work/Catalina/localhost/docs/loader&lt;BR /&gt;
   /home/jenkins/qa-automation-smcconnell/Automation/Tomcats/tomcat7/work/Catalina/localhost/manager/loader&lt;BR /&gt;
   /home/jenkins/qa-automation-smcconnell/Automation/Tomcats/tomcat7/work/Catalina/localhost/_/loader&lt;BR /&gt;
   /home/jenkins/qa-automation-smcconnell/Automation/Tomcats/tomcat7/work/Catalina/localhost/xwiki_oracle/xwiki-temp/aether-repository/org/apache/maven/doxia/doxia-core/1.3/_maven.repositories&lt;BR /&gt;
   /home/jenkins/qa-automation-smcconnell/Automation/Tomcats/tomcat7/work/Catalina/localhost/xwiki_oracle/xwiki-temp/aether-repository/org/apache/maven/doxia/doxia-core/1.3/doxia-core-1.3.pom&lt;BR /&gt;
/home/jenkins/qa-automation-smcconnell/Automation/Tomcats/tomcat7/work/Catalina/localhost/xwiki_oracle/xwiki-temp/aether-repository/org/apache/maven/doxia/doxia-core/1.3/doxia-core-1.3.pom.ahc26f05574a43e4fce&lt;BR /&gt;
/home/jenkins/qa-automation-smcconnell/Automation/Tomcats/tomcat7/work/Catalina/localhost/xwiki_oracle/xwiki-temp/aether-repository/org/apache/maven/doxia/doxia-core/1.3/doxia-core-1.3.pom.sha1.ahca7be2b392cec49e7&lt;BR /&gt;
/home/jenkins/qa-automation-smcconnell/Automation/Tomcats/tomcat7/work/Catalina/localhost/xwiki_oracle/xwiki-temp/aether-repository/org/apache/maven/doxia/doxia-core/1.3/doxia-core-1.3.pom.sha1&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 19:18:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Problem-with-regular-expression/m-p/110732#M28953</guid>
      <dc:creator>Federica_92</dc:creator>
      <dc:date>2020-09-28T19:18:09Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with regular expression</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Problem-with-regular-expression/m-p/110733#M28954</link>
      <description>&lt;P&gt;Can you post some sample events from the write_rules.csv file (one which is not working)?&lt;/P&gt;</description>
      <pubDate>Fri, 27 Mar 2015 16:28:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Problem-with-regular-expression/m-p/110733#M28954</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2015-03-27T16:28:39Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with regular expression</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Problem-with-regular-expression/m-p/110734#M28955</link>
      <description>&lt;P&gt;The query don't produce any events, and the job inspector say that there aren't match fields.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Mar 2015 16:40:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Problem-with-regular-expression/m-p/110734#M28955</guid>
      <dc:creator>Federica_92</dc:creator>
      <dc:date>2015-03-27T16:40:56Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with regular expression</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Problem-with-regular-expression/m-p/110735#M28956</link>
      <description>&lt;P&gt;Is the lookup table write_rules.csv empty? What does it return if you just run this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup write_rules.csv 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 Mar 2015 17:12:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Problem-with-regular-expression/m-p/110735#M28956</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2015-03-27T17:12:06Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with regular expression</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Problem-with-regular-expression/m-p/110736#M28957</link>
      <description>&lt;P&gt;yes, it's not empty &lt;/P&gt;</description>
      <pubDate>Fri, 27 Mar 2015 17:13:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Problem-with-regular-expression/m-p/110736#M28957</guid>
      <dc:creator>Federica_92</dc:creator>
      <dc:date>2015-03-27T17:13:36Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with regular expression</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Problem-with-regular-expression/m-p/110737#M28958</link>
      <description>&lt;P&gt;That is good. The remaining portion of the search is searching for a specific pattern (regex) and it's not able to find the pattern causing the end result to be be empty. To see if the pattern used is correct or not, please provide some sample entries from the write_rules.csv  file (which should  be added as a lookup table file).&lt;/P&gt;</description>
      <pubDate>Fri, 27 Mar 2015 17:25:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Problem-with-regular-expression/m-p/110737#M28958</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2015-03-27T17:25:45Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with regular expression</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Problem-with-regular-expression/m-p/110738#M28959</link>
      <description>&lt;P&gt;I have add it in the answer! : ) &lt;/P&gt;</description>
      <pubDate>Fri, 27 Mar 2015 17:28:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Problem-with-regular-expression/m-p/110738#M28959</guid>
      <dc:creator>Federica_92</dc:creator>
      <dc:date>2015-03-27T17:28:41Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with regular expression</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Problem-with-regular-expression/m-p/110739#M28960</link>
      <description>&lt;P&gt;Thanks, the sample entries would be helpful but I believe the problem is not in regex. &lt;/P&gt;

&lt;P&gt;When  you run this, you would have an Splunk in-built field call '_raw'. This is the default field that a rex statement work on. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main  | rex "\s\-\s\[(?&amp;lt;path_dd&amp;gt;.+)\specific_folder" | dedup path_dd | eval path="file:read:"+path_dd+"*" | sort by path| table path | outputlookup output.csv append=True
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So statement &lt;CODE&gt;| rex "\s\-\s\[(?.+)\specific_folder"&lt;/CODE&gt; is same as &lt;CODE&gt;| rex field=_raw "\s\-\s\[(?.+)\specific_folder"&lt;/CODE&gt; &lt;/P&gt;

&lt;P&gt;Whereas, when you run this (with inputlookup), there is no field with name _raw. SO here you would have to specify your field name from which the path_dd will be extracted. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup write_rules.csv | rex "(?&amp;lt;path_dd&amp;gt;.+)\/specific_folder" | table path_dd
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So, replace &lt;CODE&gt;| rex "(?.+)\/specific_folder"&lt;/CODE&gt;  with &lt;CODE&gt;| rex field=fieldFromCSVFile "(?.+)\/specific_folder"&lt;/CODE&gt; &lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 19:18:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Problem-with-regular-expression/m-p/110739#M28960</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2020-09-28T19:18:12Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with regular expression</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Problem-with-regular-expression/m-p/110740#M28961</link>
      <description>&lt;P&gt;This revised regex should do the named capture from the sample string you provided&lt;BR /&gt;
\S(?.+)tomcat7&lt;/P&gt;

&lt;P&gt;Notes on modification to regex:&lt;BR /&gt;
changed to capture any non-whitespace character (\S) before the literal value "tomcat7"&lt;BR /&gt;
also the named capture's name shouldn't contain a hyphen so changed it to pathdd&lt;BR /&gt;
tested against your supplied input string at regex101.com&lt;/P&gt;

&lt;P&gt;Match information&lt;BR /&gt;
MATCH 1&lt;BR /&gt;
pathdd  [1-58]  &lt;CODE&gt;home/jenkins/qa-automation-smcconnell/Automation/Tomcats/&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Hope this helps with the regex part of the question.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Mar 2015 21:45:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Problem-with-regular-expression/m-p/110740#M28961</guid>
      <dc:creator>paddygriffin</dc:creator>
      <dc:date>2015-03-27T21:45:15Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with regular expression</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Problem-with-regular-expression/m-p/110741#M28962</link>
      <description>&lt;P&gt;sorry for some reason the capture name was edited out when i posted the reply, possibly because or the angle brackets - i've replaced them with "lessthan" and "greaterthan" here&lt;BR /&gt;
\S(?lessthanpathddgreaterthan.+)tomcat7&lt;/P&gt;</description>
      <pubDate>Fri, 27 Mar 2015 21:50:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Problem-with-regular-expression/m-p/110741#M28962</guid>
      <dc:creator>paddygriffin</dc:creator>
      <dc:date>2015-03-27T21:50:56Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with regular expression</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Problem-with-regular-expression/m-p/110742#M28963</link>
      <description>&lt;P&gt;This revised regex should do the named capture from the sample string you provided&lt;BR /&gt;
backwardslashS(?lessthanpathddgreaterthan.+)tomcat7&lt;/P&gt;

&lt;P&gt;Notes on modification to regex:&lt;BR /&gt;
changed to capture any non-whitespace character (S) before the literal value "tomcat7"&lt;BR /&gt;
also the named capture's name shouldn't contain a hyphen so changed it to pathdd&lt;BR /&gt;
tested against your supplied input string at regex101.com&lt;/P&gt;

&lt;P&gt;Match information&lt;BR /&gt;
MATCH 1&lt;BR /&gt;
pathdd [1-58] home/jenkins/qa-automation-smcconnell/Automation/Tomcats/&lt;/P&gt;

&lt;P&gt;Hope this helps with the regex part of the question.&lt;BR /&gt;
If you're working against input from an inputlookup command I believe someson12 is correct - in the rex command you need to specify the fieldname from the csv that you want to apply the regex to.&lt;/P&gt;

&lt;P&gt;sorry for some reason the capture name was edited out when i posted the reply, possibly because or the angle brackets - i've replaced them with "lessthan" and "greaterthan" here, also the backslash at the beginning&lt;/P&gt;</description>
      <pubDate>Fri, 27 Mar 2015 21:57:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Problem-with-regular-expression/m-p/110742#M28963</guid>
      <dc:creator>paddygriffin</dc:creator>
      <dc:date>2015-03-27T21:57:27Z</dc:date>
    </item>
  </channel>
</rss>

