<?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 for extraction between text and second comma in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-extraction-between-text-and-second-comma/m-p/135668#M37106</link>
    <description>&lt;P&gt;Hi Bliide --&lt;/P&gt;

&lt;P&gt;If I understand you correctly, please correct me if I'm wrong, you would like capture the following from the above log?: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;RegNum: 5.100.1, size of 0 bytes is invalid (-2147483638)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And not the entire RegNum field, correct?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;RegNum: 5.100.1, size of 0 bytes is invalid (-2147483638), RegisterMsg.cpp line 263 (class CRegisterFromDeviceMsg).
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;For the former, you can capture it in many different ways but it would be based on the assumption that there will always be a second perior within that field. If there isn't, the regex would likely fail. If you can rely on there always being 2 periods within that field you may be able to use the following regex to capture that data.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?&amp;lt;field_name&amp;gt;RegNum\:.*\b\,.*)(?=\,)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, if you'd rather capture the entire field value you could use the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?&amp;lt;=RegNum\:\s{1})(?&amp;lt;regnum&amp;gt;.*)(?=Handled\:)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps!&lt;/P&gt;

&lt;P&gt;Kind Regards,&lt;/P&gt;

&lt;P&gt;~Brian&lt;/P&gt;</description>
    <pubDate>Wed, 09 Jul 2014 16:52:02 GMT</pubDate>
    <dc:creator>bluger_splunk</dc:creator>
    <dc:date>2014-07-09T16:52:02Z</dc:date>
    <item>
      <title>Regex for extraction between text and second comma</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-extraction-between-text-and-second-comma/m-p/135667#M37105</link>
      <description>&lt;P&gt;I am working on a field extraction.  I have created an extraction that pulls the field I want but I need it to pull even further.  I currently have it pulling data between the text I identify and the first comma.  I need it to pull from the text to the second comma.  Example of a log file is this:&lt;/P&gt;

&lt;P&gt;6/25/2014 15:05:12.724 | 18072 | EXCEPTION(V): PARN476_02HLOALP_RD:TF F RgstrData(0)(0):  RegNum: 5.100.1, size of 0 bytes is invalid (-2147483638), RegisterMsg.cpp line 263 (class CRegisterFromDeviceMsg). Handled: RegisterMsg.cpp(class CRegisterFromDeviceMsg) line 269 |  &lt;/P&gt;

&lt;P&gt;My current REGEX looks like this:&lt;/P&gt;

&lt;P&gt;(?i) regnum:(?P{FIELDNAME}[^,]+)&lt;/P&gt;

&lt;P&gt;I need to either change the regex to get everything up to the second comma or change it to find everything between RegNum: and RegisterMsg.cpp&lt;/P&gt;

&lt;P&gt;Please advise&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:01:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-extraction-between-text-and-second-comma/m-p/135667#M37105</guid>
      <dc:creator>Bliide</dc:creator>
      <dc:date>2020-09-28T17:01:35Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for extraction between text and second comma</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-extraction-between-text-and-second-comma/m-p/135668#M37106</link>
      <description>&lt;P&gt;Hi Bliide --&lt;/P&gt;

&lt;P&gt;If I understand you correctly, please correct me if I'm wrong, you would like capture the following from the above log?: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;RegNum: 5.100.1, size of 0 bytes is invalid (-2147483638)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And not the entire RegNum field, correct?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;RegNum: 5.100.1, size of 0 bytes is invalid (-2147483638), RegisterMsg.cpp line 263 (class CRegisterFromDeviceMsg).
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;For the former, you can capture it in many different ways but it would be based on the assumption that there will always be a second perior within that field. If there isn't, the regex would likely fail. If you can rely on there always being 2 periods within that field you may be able to use the following regex to capture that data.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?&amp;lt;field_name&amp;gt;RegNum\:.*\b\,.*)(?=\,)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, if you'd rather capture the entire field value you could use the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?&amp;lt;=RegNum\:\s{1})(?&amp;lt;regnum&amp;gt;.*)(?=Handled\:)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps!&lt;/P&gt;

&lt;P&gt;Kind Regards,&lt;/P&gt;

&lt;P&gt;~Brian&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jul 2014 16:52:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-extraction-between-text-and-second-comma/m-p/135668#M37106</guid>
      <dc:creator>bluger_splunk</dc:creator>
      <dc:date>2014-07-09T16:52:02Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for extraction between text and second comma</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-extraction-between-text-and-second-comma/m-p/135669#M37107</link>
      <description>&lt;P&gt;I am attempting to create a field extraction that will pull the data between the RegNum: and RegisterMsg.cpp&lt;/P&gt;

&lt;P&gt;So in the example log it would pull:&lt;/P&gt;

&lt;P&gt;5.100.1, size of 0 bytes is invalid (-2147483638)&lt;/P&gt;

&lt;P&gt;When I try to use your suggested REGEX, splunk gives me an "Invalid regex: syntex error".  I am sure it is something I am typing incorrectly. The commas are a constant in the log.  That is why I was attempting to use the second comma as the end point for the extraction.  Where in my field extraction do I plug in your suggested regex?  &lt;/P&gt;

&lt;P&gt;(?i) regnum:(?P{FIELDNAME}[^,]+)&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jul 2014 20:07:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-extraction-between-text-and-second-comma/m-p/135669#M37107</guid>
      <dc:creator>Bliide</dc:creator>
      <dc:date>2014-07-09T20:07:21Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for extraction between text and second comma</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-extraction-between-text-and-second-comma/m-p/135670#M37108</link>
      <description>&lt;P&gt;Give this a try. (replaces your whole regex)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?i) RegNum:\s(?P&amp;lt;FIELDNAME&amp;gt;.*)(,\s*\w+\.\w+) line
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Jul 2014 20:32:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-extraction-between-text-and-second-comma/m-p/135670#M37108</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-07-09T20:32:55Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for extraction between text and second comma</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-extraction-between-text-and-second-comma/m-p/135671#M37109</link>
      <description>&lt;P&gt;Works great.  What is "line" for?&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jul 2014 21:21:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-extraction-between-text-and-second-comma/m-p/135671#M37109</guid>
      <dc:creator>Bliide</dc:creator>
      <dc:date>2014-07-09T21:21:53Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for extraction between text and second comma</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-extraction-between-text-and-second-comma/m-p/135672#M37110</link>
      <description>&lt;P&gt;Its the literal string 'line' in your logs (from 'line 263'). If all your logs are similar, this word should remain same, hence I included it in regex.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jul 2014 21:55:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-extraction-between-text-and-second-comma/m-p/135672#M37110</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-07-09T21:55:36Z</dc:date>
    </item>
  </channel>
</rss>

