<?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: Receiving an error in 'rex' command in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-am-receiving-an-error-in-rex-command/m-p/647042#M223965</link>
    <description>&lt;P&gt;Thanks for the reply, I tried the below one, I am not getting an error but Statistics output is 0&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;index="myIndex" appname="myapp" msg.result.message =&lt;/SPAN&gt;&lt;SPAN&gt;"*TradingSymbol(s):*"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;| rex field =msg.result.message&amp;nbsp; "TradingSymbol(s):&amp;nbsp; (?&amp;lt;TradingSymbol&amp;gt;[^\"]*)&amp;nbsp; ElapsedTime:&amp;nbsp; (?&amp;lt;ElapsedTime&amp;gt;[^\"]*)"&lt;BR /&gt;| stats count BY TradingSymbol&amp;nbsp;ElapsedTime&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If I give only the "ElapsedTime: (?&amp;lt;ElapsedTime&amp;gt;[^\"]*)" I am able to see the required output in the Statistics tab but having the two as above, Statistics output is 0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I am new to regex, please help to resolve this:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;msg.result.message is&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;RefreshAsyncjronized&amp;nbsp;&amp;nbsp;End, TradingSymbol(s): 2AC5, 3DE2, 5CE3, 4FA4, 1BM5, TEST-2AB6,&amp;nbsp; TEST-2BA9, ElapsedTime: 12.3762658&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;on the&amp;nbsp;Statistics page, I want to display.&lt;BR /&gt;TradingSymbol&amp;nbsp;&amp;nbsp;ElapsedTime&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 14 Jun 2023 21:36:17 GMT</pubDate>
    <dc:creator>Sureshp191</dc:creator>
    <dc:date>2023-06-14T21:36:17Z</dc:date>
    <item>
      <title>Why am I am receiving an error in 'rex' command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-am-receiving-an-error-in-rex-command/m-p/647030#M223959</link>
      <description>&lt;P&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Snag_9c06d92.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/25832iC7F3C38A22E38CA1/image-size/large?v=v2&amp;amp;px=999" role="button" title="Snag_9c06d92.png" alt="Snag_9c06d92.png" /&gt;&lt;/span&gt;I am trying to use a similar splunk query:&lt;BR /&gt;&lt;BR /&gt;index="myIndex" appname="myapp" msg.result.message =&lt;/SPAN&gt;&lt;SPAN&gt;"*TradingSymbol(s):*"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;| rex "(?&amp;lt;=TradingSymbol\(s\): )[\w-]+(?:, [\w-]+)*,"&lt;BR /&gt;| stats count BY TradingSymbol(s), Elapsed&lt;BR /&gt;&lt;BR /&gt;I wanted to get them in a table as&lt;BR /&gt;Date,&amp;nbsp; PortfolioSymbol(s),&amp;nbsp; ElapsedTime&lt;BR /&gt;&lt;BR /&gt;When I try to run it, I get the error&amp;nbsp;&lt;BR /&gt;Error in 'rex' command: The regex '(?&amp;lt;=TradingSymbol\(s\): )[\w-]+(?:, [\w-]+)*,' does not extract anything. It should specify at least one named group. Format: (?&amp;lt;name&amp;gt;...).&lt;BR /&gt;&lt;BR /&gt;When I try the same in regexr.com, for the below output,&amp;nbsp;(?&amp;lt;=TradingSymbol\(s\): )[\w-]+(?:, [\w-]+)*, able to highlight&amp;nbsp;2AC5, 3DE2, 5CE3, 4FA4, 1BM5, TEST-2AB6,&amp;nbsp; TEST-2BA9, &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;RefreshAsyncjronized&amp;nbsp;&amp;nbsp;End, TradingSymbol(s): 2AC5, 3DE2, 5CE3, 4FA4, 1BM5, TEST-2AB6,&amp;nbsp; TEST-2BA9, ElapsedTime: 12.3762658&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Please help, Thanks&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2023 22:52:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-am-receiving-an-error-in-rex-command/m-p/647030#M223959</guid>
      <dc:creator>Sureshp191</dc:creator>
      <dc:date>2023-06-15T22:52:29Z</dc:date>
    </item>
    <item>
      <title>Re: Receiving an error in 'rex' command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-am-receiving-an-error-in-rex-command/m-p/647040#M223964</link>
      <description>&lt;P&gt;The error message clearly (IMO) says what the problem is - you don't have a named capture group in the rex command.&amp;nbsp; Fix that.&amp;nbsp; Also, avoid lookbehind - a simple &lt;FONT face="courier new,courier"&gt;TradingSymbol\(s):&lt;/FONT&gt; is sufficient.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2023 21:04:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-am-receiving-an-error-in-rex-command/m-p/647040#M223964</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2023-06-14T21:04:38Z</dc:date>
    </item>
    <item>
      <title>Re: Receiving an error in 'rex' command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-am-receiving-an-error-in-rex-command/m-p/647042#M223965</link>
      <description>&lt;P&gt;Thanks for the reply, I tried the below one, I am not getting an error but Statistics output is 0&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;index="myIndex" appname="myapp" msg.result.message =&lt;/SPAN&gt;&lt;SPAN&gt;"*TradingSymbol(s):*"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;| rex field =msg.result.message&amp;nbsp; "TradingSymbol(s):&amp;nbsp; (?&amp;lt;TradingSymbol&amp;gt;[^\"]*)&amp;nbsp; ElapsedTime:&amp;nbsp; (?&amp;lt;ElapsedTime&amp;gt;[^\"]*)"&lt;BR /&gt;| stats count BY TradingSymbol&amp;nbsp;ElapsedTime&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If I give only the "ElapsedTime: (?&amp;lt;ElapsedTime&amp;gt;[^\"]*)" I am able to see the required output in the Statistics tab but having the two as above, Statistics output is 0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I am new to regex, please help to resolve this:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;msg.result.message is&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;RefreshAsyncjronized&amp;nbsp;&amp;nbsp;End, TradingSymbol(s): 2AC5, 3DE2, 5CE3, 4FA4, 1BM5, TEST-2AB6,&amp;nbsp; TEST-2BA9, ElapsedTime: 12.3762658&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;on the&amp;nbsp;Statistics page, I want to display.&lt;BR /&gt;TradingSymbol&amp;nbsp;&amp;nbsp;ElapsedTime&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2023 21:36:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-am-receiving-an-error-in-rex-command/m-p/647042#M223965</guid>
      <dc:creator>Sureshp191</dc:creator>
      <dc:date>2023-06-14T21:36:17Z</dc:date>
    </item>
    <item>
      <title>Re: Receiving an error in 'rex' command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-am-receiving-an-error-in-rex-command/m-p/647072#M223966</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;&lt;/P&gt;&lt;P&gt;Thanks for the help, I tried&amp;nbsp;&lt;BR /&gt;&lt;SPAN&gt;index="myIndex" appname="myapp" msg.result.message =&lt;/SPAN&gt;&lt;SPAN&gt;"*TradingSymbol(s):*"&lt;/SPAN&gt;&lt;BR /&gt;| rex field=_raw "TradingSymbol\(s\): (?&amp;lt;TradingSymbols&amp;gt;[^,]+), ElapsedTime: (?&amp;lt;ElapsedTime&amp;gt;[^ ]+)"&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;| table TradingSymbols, Elapsed&lt;BR /&gt;&lt;BR /&gt;Even though I see around 20 plus events but on the Statics tab its zero:&lt;BR /&gt;&lt;BR /&gt;output of&amp;nbsp;msg.result.message on the events tab is:&lt;BR /&gt;RefreshAsyncjronized&amp;nbsp;&amp;nbsp;End, TradingSymbol(s): 2AC5, 3DE2, 5CE3, 4FA4, 1BM5, TEST-2AB6,&amp;nbsp; TEST-2BA9, ElapsedTime: 12.3762658&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;On the Statics tab I wanted to show as below&lt;BR /&gt;TradingSymbols&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ElapsedTime&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2AC5, 3DE2, 5CE3, 4FA4, 1BM5, TEST-2AB6,&amp;nbsp; TEST-2BA9,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;12.3762658&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2023 03:05:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-am-receiving-an-error-in-rex-command/m-p/647072#M223966</guid>
      <dc:creator>Sureshp191</dc:creator>
      <dc:date>2023-06-15T03:05:48Z</dc:date>
    </item>
    <item>
      <title>Re: Receiving an error in 'rex' command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-am-receiving-an-error-in-rex-command/m-p/647073#M223967</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/257729"&gt;@Sureshp191&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Here's a run anywhere example from the example data provided...&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval raw="RefreshAsyncjronized  End, TradingSymbol(s): 2AC5, 3DE2, 5CE3, 4FA4, 1BM5, TEST-2AB6,  TEST-2BA9, ElapsedTime: 12.3762658
RefreshAsyncjronized  End, TradingSymbol(s): 3DE2, 5CE3, 4FA4, 1BM5, TEST-2AB6,  TEST-2BA9, 2AC5, ElapsedTime: 15.3762658"
| eval raw=split(raw, "
")
| mvexpand raw
| rename raw AS _raw
  ``` the above is just creating dummy events to test the following SPL code with ```
| rex "TradingSymbol\(s\): (?&amp;lt;TradingSymbol&amp;gt;.+?), ElapsedTime: (?&amp;lt;ElapsedTime&amp;gt;[^\s]+)"
| stats values(ElapsedTime) AS ElapsedTime BY _time TradingSymbol
| rename TradingSymbol AS PortfolioSymbol(s)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Note, using _time instead of Date is useful as the UI formats into a human readable form.&amp;nbsp; If it must be Date&amp;nbsp; then you cannot simply rename _time as Date as the Date will appear as an epoch seconds integer value. You'll need to do reformat time using eval and strftime() functions.&amp;nbsp; Basically, just stick with using _time instead.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2023 03:17:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-am-receiving-an-error-in-rex-command/m-p/647073#M223967</guid>
      <dc:creator>yeahnah</dc:creator>
      <dc:date>2023-06-15T03:17:00Z</dc:date>
    </item>
  </channel>
</rss>

