<?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: Need help with a regex please. (Defining an action by user) in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Need-help-with-a-regex-please-Defining-an-action-by-user/m-p/698131#M237105</link>
    <description>&lt;P&gt;May I ask another silly question,&lt;BR /&gt;I am getting closer to what I need, if I had the following examples:&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class=""&gt;/rest/Apple/1.0&lt;/SPAN&gt;&lt;SPAN&gt;/&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class=""&gt;/rest/Banana/2&lt;/SPAN&gt;&lt;SPAN&gt;/&lt;BR /&gt;&lt;SPAN class=""&gt;/rest/structure/2.0&lt;/SPAN&gt;/&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;How could I define a variable via regex to best tease out whats an apple, banana and or structure&lt;BR /&gt;&lt;BR /&gt;I tried what you provided below but its giving me the full log.&lt;BR /&gt;I just need it to show:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex "rest/***/***"(?&amp;lt;method&amp;gt;\w+) \/rest\/(?&amp;lt;ActionTaken&amp;gt;.*)"

AKA Action taken would be equal to apple, banana or structure &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Apple 1.0&lt;/P&gt;&lt;P&gt;or Banana 2&lt;/P&gt;&lt;P&gt;structure 2.0.&amp;nbsp; (TLDR basically anything after rest/*/*/&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 03 Sep 2024 18:32:50 GMT</pubDate>
    <dc:creator>tengugurl1</dc:creator>
    <dc:date>2024-09-03T18:32:50Z</dc:date>
    <item>
      <title>Need help with a regex please. (Defining an action by user)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-with-a-regex-please-Defining-an-action-by-user/m-p/697849#M237030</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I have a standard printed statement that shows something like this:&lt;BR /&gt;&lt;BR /&gt;[&lt;/SPAN&gt;&lt;SPAN class=""&gt;29/Aug/2024:23:59:48&lt;/SPAN&gt;&lt;SPAN&gt; +&lt;/SPAN&gt;&lt;SPAN class=""&gt;0000&lt;/SPAN&gt;&lt;SPAN&gt;] "&lt;/SPAN&gt;&lt;SPAN class=""&gt;GET&lt;/SPAN&gt; &lt;SPAN class=""&gt;/rest/LMNOP&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;[&lt;/SPAN&gt;&lt;SPAN class=""&gt;29/Aug/2024:23:59:48&lt;/SPAN&gt;&lt;SPAN&gt; +&lt;/SPAN&gt;&lt;SPAN class=""&gt;0000&lt;/SPAN&gt;&lt;SPAN&gt;] "POST&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN class=""&gt;/rest/LMNOP&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[&lt;/SPAN&gt;&lt;SPAN class=""&gt;29/Aug/2024:23:59:48&lt;/SPAN&gt;&lt;SPAN&gt; +&lt;/SPAN&gt;&lt;SPAN class=""&gt;0000&lt;/SPAN&gt;&lt;SPAN&gt;] "PUT&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN class=""&gt;/rest/LMNOP&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[&lt;/SPAN&gt;&lt;SPAN class=""&gt;29/Aug/2024:23:59:48&lt;/SPAN&gt;&lt;SPAN&gt; +&lt;/SPAN&gt;&lt;SPAN class=""&gt;0000&lt;/SPAN&gt;&lt;SPAN&gt;] "DELETE&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN class=""&gt;/rest/LMNOP&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;I don't have a defined field called&amp;nbsp; "ActionTaken" in the sense, was the user doing a put, post or get etc..&lt;BR /&gt;&lt;BR /&gt;Is there a simple regex that would give me something to add to a query that would define a variable called&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;"ActionTaken"&lt;BR /&gt;&lt;BR /&gt;tried this:&lt;BR /&gt;rex "\//rest/s*(?&amp;lt;ActionTaken&amp;gt;\d{3})"&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;But it comes back with nothing&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Aug 2024 17:30:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-with-a-regex-please-Defining-an-action-by-user/m-p/697849#M237030</guid>
      <dc:creator>tengugurl1</dc:creator>
      <dc:date>2024-08-30T17:30:00Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with a regex please. (Defining an action by user)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-with-a-regex-please-Defining-an-action-by-user/m-p/697850#M237031</link>
      <description>&lt;P&gt;The existing &lt;FONT face="courier new,courier"&gt;rex&lt;/FONT&gt; command is searching for 3 digits following "rest", which does not match the sample text.&amp;nbsp; Try this command&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex "\\\"(?&amp;lt;method&amp;gt;\w+) \/rest\/(?&amp;lt;ActionTaken&amp;gt;.*)"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Aug 2024 17:43:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-with-a-regex-please-Defining-an-action-by-user/m-p/697850#M237031</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2024-08-30T17:43:26Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with a regex please. (Defining an action by user)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-with-a-regex-please-Defining-an-action-by-user/m-p/697851#M237032</link>
      <description>&lt;P&gt;try something like...&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex field=_raw ".*\/rest\/(?&amp;lt;ActionTaken&amp;gt;\w+)"&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 30 Aug 2024 17:44:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-with-a-regex-please-Defining-an-action-by-user/m-p/697851#M237032</guid>
      <dc:creator>thx</dc:creator>
      <dc:date>2024-08-30T17:44:14Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with a regex please. (Defining an action by user)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-with-a-regex-please-Defining-an-action-by-user/m-p/697857#M237036</link>
      <description>&lt;P&gt;1. Use regex101.com - it's a great tool for testing regexes.&lt;/P&gt;&lt;P&gt;2. Remember to escape backslashes and quotes if you use regex as a sting argument to the rex command.&lt;/P&gt;&lt;P&gt;3. Your regex would match three-digit-long parts of request path after the "//rest/" part (which doesn't appear in yiur events anyway), not the http method.&lt;/P&gt;&lt;P&gt;4. You need something like&lt;/P&gt;&lt;PRE&gt;| rex "\\]\\s+(?&amp;lt;ActionTaken&amp;gt;\\S+)\\s/"&lt;/PRE&gt;&lt;P&gt;(If you want to test it on regex101.com, remove extra backslashes)&lt;/P&gt;</description>
      <pubDate>Fri, 30 Aug 2024 22:15:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-with-a-regex-please-Defining-an-action-by-user/m-p/697857#M237036</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2024-08-30T22:15:39Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with a regex please. (Defining an action by user)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-with-a-regex-please-Defining-an-action-by-user/m-p/698131#M237105</link>
      <description>&lt;P&gt;May I ask another silly question,&lt;BR /&gt;I am getting closer to what I need, if I had the following examples:&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class=""&gt;/rest/Apple/1.0&lt;/SPAN&gt;&lt;SPAN&gt;/&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class=""&gt;/rest/Banana/2&lt;/SPAN&gt;&lt;SPAN&gt;/&lt;BR /&gt;&lt;SPAN class=""&gt;/rest/structure/2.0&lt;/SPAN&gt;/&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;How could I define a variable via regex to best tease out whats an apple, banana and or structure&lt;BR /&gt;&lt;BR /&gt;I tried what you provided below but its giving me the full log.&lt;BR /&gt;I just need it to show:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex "rest/***/***"(?&amp;lt;method&amp;gt;\w+) \/rest\/(?&amp;lt;ActionTaken&amp;gt;.*)"

AKA Action taken would be equal to apple, banana or structure &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Apple 1.0&lt;/P&gt;&lt;P&gt;or Banana 2&lt;/P&gt;&lt;P&gt;structure 2.0.&amp;nbsp; (TLDR basically anything after rest/*/*/&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Sep 2024 18:32:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-with-a-regex-please-Defining-an-action-by-user/m-p/698131#M237105</guid>
      <dc:creator>tengugurl1</dc:creator>
      <dc:date>2024-09-03T18:32:50Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with a regex please. (Defining an action by user)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-with-a-regex-please-Defining-an-action-by-user/m-p/698137#M237107</link>
      <description>&lt;P&gt;Since the new sample events don't have a method field (GET, POST, etc.), we can get rid of that part of the regex.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex "\/rest\/(?&amp;lt;field1&amp;gt;[^\/]+)\/(?&amp;lt;field2&amp;gt;.*)"&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 03 Sep 2024 20:12:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-with-a-regex-please-Defining-an-action-by-user/m-p/698137#M237107</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2024-09-03T20:12:07Z</dc:date>
    </item>
  </channel>
</rss>

