<?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 rex stop after first match in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/rex-stop-after-first-match/m-p/531915#M150256</link>
    <description>&lt;P&gt;i have a field with several strings like&lt;/P&gt;&lt;P&gt;fieldname = AT-field2-field3&lt;/P&gt;&lt;P&gt;fieldname = DE-field2&lt;/P&gt;&lt;P&gt;fieldname = DE-field2-field3-field4&lt;/P&gt;&lt;P&gt;etc...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I try to get a rex to just get the country code:&lt;/P&gt;&lt;P&gt;|rex field=fieldname "^(?&amp;lt;country&amp;gt;.*)-.*"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but the result is not just the&amp;nbsp; Country Code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;any ideas?&lt;/P&gt;</description>
    <pubDate>Thu, 03 Dec 2020 20:06:24 GMT</pubDate>
    <dc:creator>poisar</dc:creator>
    <dc:date>2020-12-03T20:06:24Z</dc:date>
    <item>
      <title>rex stop after first match</title>
      <link>https://community.splunk.com/t5/Splunk-Search/rex-stop-after-first-match/m-p/531915#M150256</link>
      <description>&lt;P&gt;i have a field with several strings like&lt;/P&gt;&lt;P&gt;fieldname = AT-field2-field3&lt;/P&gt;&lt;P&gt;fieldname = DE-field2&lt;/P&gt;&lt;P&gt;fieldname = DE-field2-field3-field4&lt;/P&gt;&lt;P&gt;etc...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I try to get a rex to just get the country code:&lt;/P&gt;&lt;P&gt;|rex field=fieldname "^(?&amp;lt;country&amp;gt;.*)-.*"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but the result is not just the&amp;nbsp; Country Code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;any ideas?&lt;/P&gt;</description>
      <pubDate>Thu, 03 Dec 2020 20:06:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/rex-stop-after-first-match/m-p/531915#M150256</guid>
      <dc:creator>poisar</dc:creator>
      <dc:date>2020-12-03T20:06:24Z</dc:date>
    </item>
    <item>
      <title>Re: rex stop after first match</title>
      <link>https://community.splunk.com/t5/Splunk-Search/rex-stop-after-first-match/m-p/531918#M150258</link>
      <description>&lt;P&gt;The .* operator is greedy so it will grab as many characters as it can that still match the expression.&amp;nbsp; One solution is to use the non-greedy quantifier.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;|rex field=fieldname "^(?&amp;lt;country&amp;gt;.*?)-.*"&lt;/LI-CODE&gt;&lt;P&gt;Another solution is to take everything up to the first hyphen.&amp;nbsp; Like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex field=fieldname "^(?&amp;lt;country&amp;gt;[^-]+)-"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Dec 2020 20:30:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/rex-stop-after-first-match/m-p/531918#M150258</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-12-03T20:30:46Z</dc:date>
    </item>
    <item>
      <title>Re: rex stop after first match</title>
      <link>https://community.splunk.com/t5/Splunk-Search/rex-stop-after-first-match/m-p/531929#M150264</link>
      <description>&lt;P&gt;thank you for your input. Both variants work and i learned something new &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Dec 2020 22:21:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/rex-stop-after-first-match/m-p/531929#M150264</guid>
      <dc:creator>poisar</dc:creator>
      <dc:date>2020-12-03T22:21:05Z</dc:date>
    </item>
  </channel>
</rss>

