<?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: Regex in Splunk Enterprise</title>
    <link>https://community.splunk.com/t5/Splunk-Enterprise/Regex/m-p/542199#M5117</link>
    <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957"&gt;@richgalloway&lt;/a&gt;&amp;nbsp; the text trying to match here is anything after "=", until "request" so the complete text here is&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;message=abc ef x request-id&lt;/LI-CODE&gt;</description>
    <pubDate>Wed, 03 Mar 2021 16:06:30 GMT</pubDate>
    <dc:creator>praddasg</dc:creator>
    <dc:date>2021-03-03T16:06:30Z</dc:date>
    <item>
      <title>Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Regex/m-p/542055#M5096</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am not so familiar with regex, but looking at some old query have been able to build one for my need. I am looking for help to understand how this is working in terms of regular expression and Splunk rex syntax&lt;/P&gt;&lt;P&gt;So the regex I am using is&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex field=_raw message="(?&amp;lt;message&amp;gt;.*).request"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;for the&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;message=abc ff request-id&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;where I am trying to extract anything after "=" until "request-id". There could be spaces as well&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;I think "&amp;lt;message&amp;gt;" here is the field name I want to denote&lt;/LI&gt;&lt;LI&gt;The wild card character "*" within the braces indicate everything after "message="&lt;/LI&gt;&lt;LI&gt;But I don't understand&lt;OL class="lia-list-style-type-lower-alpha"&gt;&lt;LI&gt;The use of "?". Is this part of the syntax of splunk regex or signifying anything and everything after "message=" i.e. working along with "*"&lt;/LI&gt;&lt;LI&gt;What is the use of braces here? is this indicating the section I am trying to parse?&lt;/LI&gt;&lt;LI&gt;The dot "." after "&amp;lt;message&amp;gt;". Is this splunk syntax?&lt;/LI&gt;&lt;LI&gt;The dot "." after braces. Is this denoting/delimiting/indicating the string which is present after the parsing section&lt;/LI&gt;&lt;LI&gt;The most confusing part is the use of quotes.&lt;/LI&gt;&lt;LI&gt;What would be regex if it is like "message abc ff request-id" and I want to parse anything between message and request&lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;/OL&gt;</description>
      <pubDate>Wed, 03 Mar 2021 00:51:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Regex/m-p/542055#M5096</guid>
      <dc:creator>praddasg</dc:creator>
      <dc:date>2021-03-03T00:51:24Z</dc:date>
    </item>
    <item>
      <title>Re: Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Regex/m-p/542057#M5097</link>
      <description>&lt;P&gt;The example &lt;FONT face="courier new,courier"&gt;rex&lt;/FONT&gt; command is invalid.&amp;nbsp; The regular expression must be enclosed in quotation marks, like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex field=_raw "message="(?&amp;lt;message&amp;gt;.*).request""&lt;/LI-CODE&gt;&lt;P&gt;then the embedded quotation marks must be escaped, like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex field=_raw "message=\\\"(?&amp;lt;message&amp;gt;.*).request\\\""&lt;/LI-CODE&gt;&lt;P&gt;1.&amp;nbsp; &amp;lt;message&amp;gt; denotes the name of the capture group and is the name of the field the matching text will fill.&lt;/P&gt;&lt;P&gt;2.&amp;nbsp; The regex wildcard character is &lt;FONT face="courier new,courier"&gt;.&lt;/FONT&gt; (full stop).&amp;nbsp; The asterisk (&lt;FONT face="courier new,courier"&gt;*&lt;/FONT&gt;) is a quantifier that means "any number of these".&amp;nbsp; The sequence .* ("dot-star") means "everything from here on".&lt;/P&gt;&lt;P&gt;3a. The "&lt;FONT face="courier new,courier"&gt;?&lt;/FONT&gt;" means nothing by itself in this context.&amp;nbsp; The "(?" sequence starts a capture group.&lt;/P&gt;&lt;P&gt;b. There are no braces in this regex so do you mean the parentheses or the angle brackets?&amp;nbsp; In this context, the parentheses denote a capture group and the angle brackets denote the name of the current capture group.&amp;nbsp; In Splunk, this becomes a field name.&lt;/P&gt;&lt;P&gt;c. Like mentioned in 2 above, the dot is the wildcard character.&amp;nbsp; Is it standard regex, not specific to Splunk.&lt;/P&gt;&lt;P&gt;d. See 2 and c.&lt;/P&gt;&lt;P&gt;e.&amp;nbsp; Quotation marks are not special characters in regex.&amp;nbsp; They're just another character to match.&amp;nbsp; On the other hand, embedded quotation marks in the &lt;FONT face="courier new,courier"&gt;rex&lt;/FONT&gt; command ARE confusing.&amp;nbsp; They require 3 escape characters to get through the various parsers to the regex engine.&lt;/P&gt;&lt;P&gt;f. Something like "message (.*) request".&lt;/P&gt;&lt;P&gt;If you pass a regex string into &lt;A href="https://regex101.com" target="_blank"&gt;https://regex101.com&lt;/A&gt;&amp;nbsp;the site will explain what each character means.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Mar 2021 01:07:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Regex/m-p/542057#M5097</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2021-03-03T01:07:01Z</dc:date>
    </item>
    <item>
      <title>Re: Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Regex/m-p/542179#M5115</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957"&gt;@richgalloway&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for taking the time and explaining.&amp;nbsp;I really appreciate the time you vested in explaining this.&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Interestingly this one works&amp;nbsp;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex field=_raw message="(?&amp;lt;message&amp;gt;.*).request"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So does the&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex field=_raw "message="(?&amp;lt;message&amp;gt;.*).request""&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but not the&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;"message=\\\"(?&amp;lt;message&amp;gt;.*).request\\\""&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;when I say work, I mean it is giving the desired result and by not working I mean not giving the desired result. Although in none of the cases there wasn't any syntax error.&lt;/P&gt;&lt;P&gt;The one with the escaped quotation mark only gives the result until before the spaces i.e. if it is "message=abc efg request-id", it only prints "abc". Does this have anything to do with the Splunk version?&lt;/P&gt;&lt;P&gt;2. Regarding&amp;nbsp;&lt;U&gt;&lt;STRONG&gt;The sequence .* ("dot-star") means "everything from here on"&lt;/STRONG&gt;&lt;/U&gt;&amp;nbsp; - I am assuming this regex and nothing to do with Splunk itself. So I tried to use this concept in a sublime text editor to see what happens. I used&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;message=Error translating Grubhub webhook order: The location for this order cannot be found request-id&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and tried to replace&amp;nbsp;&lt;STRONG&gt;message=.*&amp;nbsp;&lt;/STRONG&gt;with let's say&amp;nbsp;&lt;STRONG&gt;new&lt;/STRONG&gt;. I found the entire thing got wiped out and replaced with &lt;STRONG&gt;new&lt;/STRONG&gt;. I was expecting something like&amp;nbsp;&lt;STRONG&gt;message=new&lt;/STRONG&gt;. I even tried&amp;nbsp;&lt;STRONG&gt;message="(?.*).request",&amp;nbsp;"message="(?.*).request""&lt;/STRONG&gt;, but no changes happened. Is it because Splunk uses some different regex logic than sublime text editor?&lt;/P&gt;&lt;P&gt;3. I am still confused about the use of quotation mark, I tried using the website which you mentioned, but it confused me more lol.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Mar 2021 14:47:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Regex/m-p/542179#M5115</guid>
      <dc:creator>praddasg</dc:creator>
      <dc:date>2021-03-03T14:47:26Z</dc:date>
    </item>
    <item>
      <title>Re: Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Regex/m-p/542193#M5116</link>
      <description>&lt;P&gt;To know whether a regex works or not requires knowing the text it is trying to match.&amp;nbsp; Please share.&lt;/P&gt;&lt;P&gt;I don't know which regex version Sublime uses, but Splunk uses PCRE.&amp;nbsp; Also, Splunk is not a text editor so it may behave differently from an editor.&lt;/P&gt;&lt;P&gt;You may find this helpful:&amp;nbsp;&lt;A href="https://conf.splunk.com/files/2017/slides/regex-in-your-spl.pdf" target="_blank"&gt;https://conf.splunk.com/files/2017/slides/regex-in-your-spl.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Mar 2021 15:50:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Regex/m-p/542193#M5116</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2021-03-03T15:50:26Z</dc:date>
    </item>
    <item>
      <title>Re: Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Regex/m-p/542199#M5117</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957"&gt;@richgalloway&lt;/a&gt;&amp;nbsp; the text trying to match here is anything after "=", until "request" so the complete text here is&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;message=abc ef x request-id&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 03 Mar 2021 16:06:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Regex/m-p/542199#M5117</guid>
      <dc:creator>praddasg</dc:creator>
      <dc:date>2021-03-03T16:06:30Z</dc:date>
    </item>
    <item>
      <title>Re: Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Regex/m-p/542202#M5118</link>
      <description>&lt;P&gt;oh one more thing, the content between "=" and "request" could be any number of character or number and can have multiple spaces as well&lt;/P&gt;</description>
      <pubDate>Wed, 03 Mar 2021 16:11:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Regex/m-p/542202#M5118</guid>
      <dc:creator>praddasg</dc:creator>
      <dc:date>2021-03-03T16:11:21Z</dc:date>
    </item>
    <item>
      <title>Re: Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Regex/m-p/542227#M5122</link>
      <description>&lt;LI-CODE lang="markup"&gt;"=.*?request"&lt;/LI-CODE&gt;&lt;P&gt;The question mark limits the scope of the asterisk to the fewest number of characters needed to match the regex.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Mar 2021 17:52:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Regex/m-p/542227#M5122</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2021-03-03T17:52:42Z</dc:date>
    </item>
  </channel>
</rss>

