<?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 Regex Help in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Regex-Help/m-p/700724#M237750</link>
    <description>&lt;P&gt;probably a basic question&lt;/P&gt;&lt;P&gt;i have the following data&amp;nbsp;&lt;/P&gt;&lt;P&gt;600 reason&lt;/P&gt;&lt;P&gt;and this rex&lt;/P&gt;&lt;P&gt;(?&amp;lt;MetricValue&amp;gt;([^\s))]+))(?&amp;lt;Reason&amp;gt;([^:|^R]+))&lt;/P&gt;&lt;P&gt;what i am getting is 60 in Metric Value and 0 in Reason&lt;/P&gt;&lt;P&gt;i presume that is due to the match being up to the next NOT space, thus metric value is 60 and 0 remains in the data for Reason&lt;/P&gt;&lt;P&gt;what is the right way to do this such that i get value = 600 and reason = reason&lt;/P&gt;</description>
    <pubDate>Tue, 01 Oct 2024 23:02:31 GMT</pubDate>
    <dc:creator>darkins</dc:creator>
    <dc:date>2024-10-01T23:02:31Z</dc:date>
    <item>
      <title>Regex Help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Help/m-p/700724#M237750</link>
      <description>&lt;P&gt;probably a basic question&lt;/P&gt;&lt;P&gt;i have the following data&amp;nbsp;&lt;/P&gt;&lt;P&gt;600 reason&lt;/P&gt;&lt;P&gt;and this rex&lt;/P&gt;&lt;P&gt;(?&amp;lt;MetricValue&amp;gt;([^\s))]+))(?&amp;lt;Reason&amp;gt;([^:|^R]+))&lt;/P&gt;&lt;P&gt;what i am getting is 60 in Metric Value and 0 in Reason&lt;/P&gt;&lt;P&gt;i presume that is due to the match being up to the next NOT space, thus metric value is 60 and 0 remains in the data for Reason&lt;/P&gt;&lt;P&gt;what is the right way to do this such that i get value = 600 and reason = reason&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2024 23:02:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Help/m-p/700724#M237750</guid>
      <dc:creator>darkins</dc:creator>
      <dc:date>2024-10-01T23:02:31Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Help/m-p/700725#M237751</link>
      <description>&lt;P&gt;Actually most of your problem is coming from multiple capture groups inside a capture group designated by each "()" pairing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults format=csv data="sample
600 reason and more:then what
701 code practice Reason
899 something
104 this
12 nothing"
| rex field=sample "^(?&amp;lt;Metric&amp;gt;[^\s]+)\s(?&amp;lt;Reason&amp;gt;[^:|^R]+).*$"
| table sample Metric Reason&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can see in my example that after the &amp;lt;field&amp;gt; I did not nest additional capture group designations such as what you were using.&amp;nbsp; The above generates some random data which I hope fits your use case but you provided minimal examples so I made assumptions.&amp;nbsp; The rex as coded would with draw the information you are looking for assuming that the Metric is the first one the line or field and following that is the Reason with your indicated cut off characters or end of line like I indicated.&amp;nbsp; Feel free to remove the indicators for beginning of line and end of line if they don't fit your data.&lt;/P&gt;&lt;P&gt;Here is the output I get.&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;sample&lt;/TD&gt;&lt;TD&gt;Metric&lt;/TD&gt;&lt;TD&gt;Reason&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;600 reason and more:then what&lt;/TD&gt;&lt;TD&gt;600&lt;/TD&gt;&lt;TD&gt;reason and more&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;701 code practice Reason&lt;/TD&gt;&lt;TD&gt;701&lt;/TD&gt;&lt;TD&gt;code practice&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;899 something&lt;/TD&gt;&lt;TD&gt;899&lt;/TD&gt;&lt;TD&gt;something&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;104 this&lt;/TD&gt;&lt;TD&gt;104&lt;/TD&gt;&lt;TD&gt;this&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12 nothing&lt;/TD&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;TD&gt;nothing&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Oct 2024 00:05:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Help/m-p/700725#M237751</guid>
      <dc:creator>dural_yyz</dc:creator>
      <dc:date>2024-10-02T00:05:46Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Help/m-p/700726#M237752</link>
      <description>&lt;P&gt;Given the complexity of the regex, I suspect the sample event may be over-simplified.&amp;nbsp; However, if it's a matter of the value field is an integer followed by a space then everything goes into the reason field then this &lt;FONT face="courier new,courier"&gt;rex&lt;/FONT&gt; command will do.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex "(?&amp;lt;MetricValue&amp;gt;\d+)\s(?&amp;lt;Reason&amp;gt;.*)"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Oct 2024 00:06:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Help/m-p/700726#M237752</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2024-10-02T00:06:47Z</dc:date>
    </item>
  </channel>
</rss>

