<?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: rex expression that match pathname of variable lenght in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/rex-expression-that-match-pathname-of-variable-lenght/m-p/138387#M37979</link>
    <description>&lt;P&gt;Federica, looking at your framework question, the reason those won't work is because you're not creating the field.&lt;/P&gt;

&lt;P&gt;For your reference, it'll benefit you in the long term.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex "\[(?P&amp;lt;path&amp;gt;[^\]]*)\]"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The &lt;CODE&gt;&amp;lt; path &amp;gt;&lt;/CODE&gt; part of the rex, creates the field called path    &lt;/P&gt;

&lt;P&gt;Using the example you supplied, this is missing.  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search: mvc.tokenSafe ("index=waratek source=$sourcename$ File:read | rex '[[^*](?.+)]' | fields path | outputlookup read_rules.csv")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Try:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search: mvc.tokenSafe ("index=waratek source=$sourcename$ File:read | rex '\[(?P&amp;lt;path&amp;gt;[^\]]*)\]' | fields path | outputlookup read_rules.csv")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Credit to @richgalloway for the rex statement.&lt;/P&gt;</description>
    <pubDate>Thu, 26 Feb 2015 10:17:50 GMT</pubDate>
    <dc:creator>markthompson</dc:creator>
    <dc:date>2015-02-26T10:17:50Z</dc:date>
    <item>
      <title>rex expression that match pathname of variable lenght</title>
      <link>https://community.splunk.com/t5/Splunk-Search/rex-expression-that-match-pathname-of-variable-lenght/m-p/138376#M37968</link>
      <description>&lt;P&gt;Hi all, &lt;BR /&gt;
quick question:&lt;BR /&gt;
How I can match with rex or regex a regular expression that match all of this field? &lt;/P&gt;

&lt;P&gt;[/home/nheffernan/Waratek/apache-tomcat-7.0.52/webapps/host-manager.war]&lt;BR /&gt;
[/home/nheffernan/Waratek/apache-tomcat-7.0.52/conf/context.xml]&lt;BR /&gt;
[/home/nheffernan/Waratek/apache-tomcat-7.0.52/webapps/ROOT/META-INF/context.xml]&lt;BR /&gt;
[/home/nheffernan/Waratek/apache-tomcat-7.0.52/webapps/docs/]&lt;BR /&gt;
and so on.. &lt;BR /&gt;
These are raw data, and I would like extract a field that contain for each event the pathname &lt;BR /&gt;
such as: path=/home/nheffernan/Waratek/apache-tomcat-7.0.52/webapps/host-manager.war&lt;/P&gt;

&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Mon, 16 Feb 2015 17:05:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/rex-expression-that-match-pathname-of-variable-lenght/m-p/138376#M37968</guid>
      <dc:creator>Federica_92</dc:creator>
      <dc:date>2015-02-16T17:05:16Z</dc:date>
    </item>
    <item>
      <title>Re: rex expression that match pathname of variable lenght</title>
      <link>https://community.splunk.com/t5/Splunk-Search/rex-expression-that-match-pathname-of-variable-lenght/m-p/138377#M37969</link>
      <description>&lt;P&gt;Does this work?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex "\[(?P&amp;lt;path&amp;gt;[^\]]*)\]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Feb 2015 18:24:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/rex-expression-that-match-pathname-of-variable-lenght/m-p/138377#M37969</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2015-02-16T18:24:09Z</dc:date>
    </item>
    <item>
      <title>Re: rex expression that match pathname of variable lenght</title>
      <link>https://community.splunk.com/t5/Splunk-Search/rex-expression-that-match-pathname-of-variable-lenght/m-p/138378#M37970</link>
      <description>&lt;P&gt;Thank you, &lt;BR /&gt;
This one works: rex "[\/(?P[^]]*)]" &lt;/P&gt;

&lt;P&gt;But how can I export one csv file that contains only this path?&lt;/P&gt;

&lt;P&gt;index=main| rex "[(?P[^]]*)]" | outputlookup users.csv , but in the csv file I would like have only the rex field&lt;/P&gt;</description>
      <pubDate>Tue, 17 Feb 2015 10:05:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/rex-expression-that-match-pathname-of-variable-lenght/m-p/138378#M37970</guid>
      <dc:creator>Federica_92</dc:creator>
      <dc:date>2015-02-17T10:05:47Z</dc:date>
    </item>
    <item>
      <title>Re: rex expression that match pathname of variable lenght</title>
      <link>https://community.splunk.com/t5/Splunk-Search/rex-expression-that-match-pathname-of-variable-lenght/m-p/138379#M37971</link>
      <description>&lt;P&gt;Insert a &lt;CODE&gt;fields&lt;/CODE&gt; command before the outputlookup.  Only the fields listed in the command will be written to the CSV.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Feb 2015 13:54:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/rex-expression-that-match-pathname-of-variable-lenght/m-p/138379#M37971</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2015-02-17T13:54:10Z</dc:date>
    </item>
    <item>
      <title>Re: rex expression that match pathname of variable lenght</title>
      <link>https://community.splunk.com/t5/Splunk-Search/rex-expression-that-match-pathname-of-variable-lenght/m-p/138380#M37972</link>
      <description>&lt;P&gt;yeah, but with fields command I have to tell to splunk the name of the rex field...&lt;/P&gt;

&lt;P&gt;index=main| rex "[(?P[^]]*)]" | fields name rex field outputlookup users.csv &lt;/P&gt;</description>
      <pubDate>Tue, 17 Feb 2015 13:57:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/rex-expression-that-match-pathname-of-variable-lenght/m-p/138380#M37972</guid>
      <dc:creator>Federica_92</dc:creator>
      <dc:date>2015-02-17T13:57:38Z</dc:date>
    </item>
    <item>
      <title>Re: rex expression that match pathname of variable lenght</title>
      <link>https://community.splunk.com/t5/Splunk-Search/rex-expression-that-match-pathname-of-variable-lenght/m-p/138381#M37973</link>
      <description>&lt;P&gt;So give it a name.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main| rex "\[(?P&amp;lt;path&amp;gt;[^\]]*)\]" | fields path | outputlookup users.csv 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 17 Feb 2015 14:00:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/rex-expression-that-match-pathname-of-variable-lenght/m-p/138381#M37973</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2015-02-17T14:00:49Z</dc:date>
    </item>
    <item>
      <title>Re: rex expression that match pathname of variable lenght</title>
      <link>https://community.splunk.com/t5/Splunk-Search/rex-expression-that-match-pathname-of-variable-lenght/m-p/138382#M37974</link>
      <description>&lt;P&gt;seems works! And last question, how I can add it at my query in the framework?&lt;/P&gt;

&lt;P&gt;search: mvc.tokenSafe ("index=waratek  source=$sourcename$ File:read | rex '[&lt;A href="https://community.splunk.com/?.+"&gt;^*&lt;/A&gt;]' | fields path | outputlookup read_rules.csv")&lt;/P&gt;

&lt;P&gt;search: mvc.tokenSafe ("index=waratek  source=$sourcename$ File:read | rex "[&lt;A href="https://community.splunk.com/?.+"&gt;^*&lt;/A&gt;]" | fields path | outputlookup read_rules.csv")&lt;/P&gt;

&lt;P&gt;I cannot use these ways&lt;/P&gt;</description>
      <pubDate>Tue, 17 Feb 2015 14:14:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/rex-expression-that-match-pathname-of-variable-lenght/m-p/138382#M37974</guid>
      <dc:creator>Federica_92</dc:creator>
      <dc:date>2015-02-17T14:14:55Z</dc:date>
    </item>
    <item>
      <title>Re: rex expression that match pathname of variable lenght</title>
      <link>https://community.splunk.com/t5/Splunk-Search/rex-expression-that-match-pathname-of-variable-lenght/m-p/138383#M37975</link>
      <description>&lt;P&gt;I'm not familiar with the framework.  Why can you not use those ways?&lt;/P&gt;</description>
      <pubDate>Tue, 17 Feb 2015 14:24:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/rex-expression-that-match-pathname-of-variable-lenght/m-p/138383#M37975</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2015-02-17T14:24:59Z</dc:date>
    </item>
    <item>
      <title>Re: rex expression that match pathname of variable lenght</title>
      <link>https://community.splunk.com/t5/Splunk-Search/rex-expression-that-match-pathname-of-variable-lenght/m-p/138384#M37976</link>
      <description>&lt;P&gt;No your query is perfect, but I have need to use it in the framework : ~)&lt;/P&gt;</description>
      <pubDate>Tue, 17 Feb 2015 14:26:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/rex-expression-that-match-pathname-of-variable-lenght/m-p/138384#M37976</guid>
      <dc:creator>Federica_92</dc:creator>
      <dc:date>2015-02-17T14:26:46Z</dc:date>
    </item>
    <item>
      <title>Re: rex expression that match pathname of variable lenght</title>
      <link>https://community.splunk.com/t5/Splunk-Search/rex-expression-that-match-pathname-of-variable-lenght/m-p/138385#M37977</link>
      <description>&lt;P&gt;What framework are you referring to?&lt;/P&gt;</description>
      <pubDate>Tue, 17 Feb 2015 14:50:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/rex-expression-that-match-pathname-of-variable-lenght/m-p/138385#M37977</guid>
      <dc:creator>esix_splunk</dc:creator>
      <dc:date>2015-02-17T14:50:34Z</dc:date>
    </item>
    <item>
      <title>Re: rex expression that match pathname of variable lenght</title>
      <link>https://community.splunk.com/t5/Splunk-Search/rex-expression-that-match-pathname-of-variable-lenght/m-p/138386#M37978</link>
      <description>&lt;P&gt;splunk framework &lt;/P&gt;</description>
      <pubDate>Tue, 17 Feb 2015 14:50:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/rex-expression-that-match-pathname-of-variable-lenght/m-p/138386#M37978</guid>
      <dc:creator>Federica_92</dc:creator>
      <dc:date>2015-02-17T14:50:35Z</dc:date>
    </item>
    <item>
      <title>Re: rex expression that match pathname of variable lenght</title>
      <link>https://community.splunk.com/t5/Splunk-Search/rex-expression-that-match-pathname-of-variable-lenght/m-p/138387#M37979</link>
      <description>&lt;P&gt;Federica, looking at your framework question, the reason those won't work is because you're not creating the field.&lt;/P&gt;

&lt;P&gt;For your reference, it'll benefit you in the long term.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex "\[(?P&amp;lt;path&amp;gt;[^\]]*)\]"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The &lt;CODE&gt;&amp;lt; path &amp;gt;&lt;/CODE&gt; part of the rex, creates the field called path    &lt;/P&gt;

&lt;P&gt;Using the example you supplied, this is missing.  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search: mvc.tokenSafe ("index=waratek source=$sourcename$ File:read | rex '[[^*](?.+)]' | fields path | outputlookup read_rules.csv")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Try:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search: mvc.tokenSafe ("index=waratek source=$sourcename$ File:read | rex '\[(?P&amp;lt;path&amp;gt;[^\]]*)\]' | fields path | outputlookup read_rules.csv")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Credit to @richgalloway for the rex statement.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Feb 2015 10:17:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/rex-expression-that-match-pathname-of-variable-lenght/m-p/138387#M37979</guid>
      <dc:creator>markthompson</dc:creator>
      <dc:date>2015-02-26T10:17:50Z</dc:date>
    </item>
  </channel>
</rss>

