<?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: PCRE Regex not working in Splunk in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/PCRE-Regex-not-working-in-Splunk/m-p/468723#M131979</link>
    <description>&lt;P&gt;Be aware that RegEx101.com does not start our in &lt;CODE&gt;PCRE&lt;/CODE&gt; mode, you have to SET IT THAT WAY by selecting the &lt;CODE&gt;PCRE (PHP)&lt;/CODE&gt; option under the &lt;CODE&gt;Flavors&lt;/CODE&gt; menu in the left pane!  Also note on the very right edge of the RegEx text input it shows some &lt;CODE&gt;REGEX FLAGS&lt;/CODE&gt; of which &lt;CODE&gt;g&lt;/CODE&gt; and &lt;CODE&gt;m&lt;/CODE&gt; are set by default but only the &lt;CODE&gt;g&lt;/CODE&gt; is always correct for Splunk.  For example, &lt;CODE&gt;rex&lt;/CODE&gt; and &lt;CODE&gt;regex&lt;/CODE&gt; commands DO NOT use &lt;CODE&gt;m&lt;/CODE&gt; by default (but &lt;CODE&gt;LINE_BREAKER&lt;/CODE&gt; does), so you must prefix your RegEx with &lt;CODE&gt;(?m)&lt;/CODE&gt; to make it work the same way in Splunk (or de-select the &lt;CODE&gt;m&lt;/CODE&gt; flag on RegEx101.com).&lt;/P&gt;

&lt;P&gt;Also be aware that splunk has both &lt;CODE&gt;pcregextest&lt;/CODE&gt; and &lt;CODE&gt;regextest&lt;/CODE&gt; CLI tools that you can use:&lt;BR /&gt;
&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/Admin/CLIadmincommands"&gt;https://docs.splunk.com/Documentation/Splunk/latest/Admin/CLIadmincommands&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 26 Dec 2019 20:00:06 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2019-12-26T20:00:06Z</dc:date>
    <item>
      <title>PCRE Regex not working in Splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/PCRE-Regex-not-working-in-Splunk/m-p/468715#M131971</link>
      <description>&lt;P&gt;Required API call, RegEx i tried in &lt;A href="https://regex101.com/"&gt;https://regex101.com/&lt;/A&gt; and the Regex which works in Splunk are given below.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;/Contact/v1/15965755/Order
\/Contact\/v1\/[0-9]{1,}/Order
/Contact/v1/*/Order
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Why PCRE regex not working in Splunk? If i add $ at the end to limit the search, that also not working.&lt;BR /&gt;
Somebody please throw some light on this.&lt;/P&gt;

&lt;P&gt;Thanks...&lt;/P&gt;</description>
      <pubDate>Fri, 20 Dec 2019 11:04:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/PCRE-Regex-not-working-in-Splunk/m-p/468715#M131971</guid>
      <dc:creator>eprince</dc:creator>
      <dc:date>2019-12-20T11:04:47Z</dc:date>
    </item>
    <item>
      <title>Re: PCRE Regex not working in Splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/PCRE-Regex-not-working-in-Splunk/m-p/468716#M131972</link>
      <description>&lt;P&gt;What isn't working for you?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
|  eval data = "/Contact/v1/15965755/Order"
| rex field=data "^\/Contact\/v1\/(?&amp;lt;field&amp;gt;[0-9]{1,})/Order$"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Dec 2019 15:39:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/PCRE-Regex-not-working-in-Splunk/m-p/468716#M131972</guid>
      <dc:creator>bshuler_splunk</dc:creator>
      <dc:date>2019-12-20T15:39:29Z</dc:date>
    </item>
    <item>
      <title>Re: PCRE Regex not working in Splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/PCRE-Regex-not-working-in-Splunk/m-p/468717#M131973</link>
      <description>&lt;P&gt;\/Contact\/v1\/[0-9]{1,}/Order is not working in Splunk to return /Contact/v1/15965755/Order.&lt;BR /&gt;
But its working in RegEx101 online validation.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Dec 2019 16:12:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/PCRE-Regex-not-working-in-Splunk/m-p/468717#M131973</guid>
      <dc:creator>eprince</dc:creator>
      <dc:date>2019-12-20T16:12:22Z</dc:date>
    </item>
    <item>
      <title>Re: PCRE Regex not working in Splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/PCRE-Regex-not-working-in-Splunk/m-p/468718#M131974</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw="/Contact/v1/15965755/Order"
| rex "(?&amp;lt;=\/)(?&amp;lt;value&amp;gt;\d+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hi, @eprince &lt;BR /&gt;
Some strange signs may be in it, so what about this?&lt;/P&gt;</description>
      <pubDate>Sat, 21 Dec 2019 01:05:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/PCRE-Regex-not-working-in-Splunk/m-p/468718#M131974</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2019-12-21T01:05:05Z</dc:date>
    </item>
    <item>
      <title>Re: PCRE Regex not working in Splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/PCRE-Regex-not-working-in-Splunk/m-p/468719#M131975</link>
      <description>&lt;P&gt;Line #2 is missing an escape on the backslash preceding "/Order".&lt;/P&gt;

&lt;P&gt;Try this:&lt;BR /&gt;
\/Contact\/v1\/[0-9]{1,}\/Order&lt;/P&gt;</description>
      <pubDate>Sun, 22 Dec 2019 23:45:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/PCRE-Regex-not-working-in-Splunk/m-p/468719#M131975</guid>
      <dc:creator>mydog8it</dc:creator>
      <dc:date>2019-12-22T23:45:54Z</dc:date>
    </item>
    <item>
      <title>Re: PCRE Regex not working in Splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/PCRE-Regex-not-working-in-Splunk/m-p/468720#M131976</link>
      <description>&lt;P&gt;That's right. &lt;/P&gt;</description>
      <pubDate>Sun, 22 Dec 2019 23:55:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/PCRE-Regex-not-working-in-Splunk/m-p/468720#M131976</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2019-12-22T23:55:00Z</dc:date>
    </item>
    <item>
      <title>Re: PCRE Regex not working in Splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/PCRE-Regex-not-working-in-Splunk/m-p/468721#M131977</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;

&lt;P&gt;Check this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval temp="/Contact/v1/15965755/Order" 
| rex field=temp "(?P&amp;lt;result&amp;gt;\d+[^\/])"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 23 Dec 2019 06:26:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/PCRE-Regex-not-working-in-Splunk/m-p/468721#M131977</guid>
      <dc:creator>vnravikumar</dc:creator>
      <dc:date>2019-12-23T06:26:58Z</dc:date>
    </item>
    <item>
      <title>Re: PCRE Regex not working in Splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/PCRE-Regex-not-working-in-Splunk/m-p/468722#M131978</link>
      <description>&lt;P&gt;I like to keep things simple with lookaround constructs. Very powerful, easy to maintain, and worth exploring for cases like this.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex "(?&amp;lt;orderNum&amp;gt;\d+)(?=\/Order)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Translation: Grab the numbers that precede /Order. See &lt;A href="https://regex101.com/r/Qq2qaV/1"&gt;https://regex101.com/r/Qq2qaV/1&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Dec 2019 16:51:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/PCRE-Regex-not-working-in-Splunk/m-p/468722#M131978</guid>
      <dc:creator>jpolvino</dc:creator>
      <dc:date>2019-12-26T16:51:09Z</dc:date>
    </item>
    <item>
      <title>Re: PCRE Regex not working in Splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/PCRE-Regex-not-working-in-Splunk/m-p/468723#M131979</link>
      <description>&lt;P&gt;Be aware that RegEx101.com does not start our in &lt;CODE&gt;PCRE&lt;/CODE&gt; mode, you have to SET IT THAT WAY by selecting the &lt;CODE&gt;PCRE (PHP)&lt;/CODE&gt; option under the &lt;CODE&gt;Flavors&lt;/CODE&gt; menu in the left pane!  Also note on the very right edge of the RegEx text input it shows some &lt;CODE&gt;REGEX FLAGS&lt;/CODE&gt; of which &lt;CODE&gt;g&lt;/CODE&gt; and &lt;CODE&gt;m&lt;/CODE&gt; are set by default but only the &lt;CODE&gt;g&lt;/CODE&gt; is always correct for Splunk.  For example, &lt;CODE&gt;rex&lt;/CODE&gt; and &lt;CODE&gt;regex&lt;/CODE&gt; commands DO NOT use &lt;CODE&gt;m&lt;/CODE&gt; by default (but &lt;CODE&gt;LINE_BREAKER&lt;/CODE&gt; does), so you must prefix your RegEx with &lt;CODE&gt;(?m)&lt;/CODE&gt; to make it work the same way in Splunk (or de-select the &lt;CODE&gt;m&lt;/CODE&gt; flag on RegEx101.com).&lt;/P&gt;

&lt;P&gt;Also be aware that splunk has both &lt;CODE&gt;pcregextest&lt;/CODE&gt; and &lt;CODE&gt;regextest&lt;/CODE&gt; CLI tools that you can use:&lt;BR /&gt;
&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/Admin/CLIadmincommands"&gt;https://docs.splunk.com/Documentation/Splunk/latest/Admin/CLIadmincommands&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Dec 2019 20:00:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/PCRE-Regex-not-working-in-Splunk/m-p/468723#M131979</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-12-26T20:00:06Z</dc:date>
    </item>
  </channel>
</rss>

