<?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 help - only check first occurrence in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/regex-help-only-check-first-occurrence/m-p/123255#M33273</link>
    <description>&lt;P&gt;didn't really read the question right. see update above.&lt;/P&gt;</description>
    <pubDate>Thu, 31 Oct 2013 07:50:11 GMT</pubDate>
    <dc:creator>kristian_kolb</dc:creator>
    <dc:date>2013-10-31T07:50:11Z</dc:date>
    <item>
      <title>regex help - only check first occurrence</title>
      <link>https://community.splunk.com/t5/Splunk-Search/regex-help-only-check-first-occurrence/m-p/123249#M33267</link>
      <description>&lt;P&gt;I've been attempting to create a regex in &lt;CODE&gt;transforms.conf&lt;/CODE&gt; that will keep events that have Value1 or Value2 and send all others to the nullQueue. My current expression works except that it will also keep the event if Value1 or Value2 occurs later in the event. I only care about the value for the first field value pair.&lt;/P&gt;

&lt;P&gt;Sample events: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Event1 outgoing Field:Value1 username:value text:value Field:Value1 Field:Value2
Event2 outgoing Field:Value2 username:value text:value Field:Value1 Field:Value2
Event3 outgoing Field:Value3 username:value text:value Field:Value1 Field:Value2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Current regex: &lt;CODE&gt;^(?!.*?Field.(Value1|Value2)\b).*$&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;In the above example, I would only want to keep the first two event. Is there a way to make this work?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Oct 2013 21:46:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/regex-help-only-check-first-occurrence/m-p/123249#M33267</guid>
      <dc:creator>sc0tt</dc:creator>
      <dc:date>2013-10-30T21:46:19Z</dc:date>
    </item>
    <item>
      <title>Re: regex help - only check first occurrence</title>
      <link>https://community.splunk.com/t5/Splunk-Search/regex-help-only-check-first-occurrence/m-p/123250#M33268</link>
      <description>&lt;P&gt;What is your current regex?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Oct 2013 21:49:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/regex-help-only-check-first-occurrence/m-p/123250#M33268</guid>
      <dc:creator>lukejadamec</dc:creator>
      <dc:date>2013-10-30T21:49:20Z</dc:date>
    </item>
    <item>
      <title>Re: regex help - only check first occurrence</title>
      <link>https://community.splunk.com/t5/Splunk-Search/regex-help-only-check-first-occurrence/m-p/123251#M33269</link>
      <description>&lt;P&gt;Just updated it.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Oct 2013 21:51:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/regex-help-only-check-first-occurrence/m-p/123251#M33269</guid>
      <dc:creator>sc0tt</dc:creator>
      <dc:date>2013-10-30T21:51:56Z</dc:date>
    </item>
    <item>
      <title>Re: regex help - only check first occurrence</title>
      <link>https://community.splunk.com/t5/Splunk-Search/regex-help-only-check-first-occurrence/m-p/123252#M33270</link>
      <description>&lt;P&gt;How structured/predictable is the text leading up to the first &lt;CODE&gt;field:value&lt;/CODE&gt; pair? Sample events, please.&lt;/P&gt;

&lt;P&gt;Can you base your decision on a fixed number of non-space, space sequences, or is there a particular string that will occur before the value you want to match?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Oct 2013 21:57:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/regex-help-only-check-first-occurrence/m-p/123252#M33270</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-10-30T21:57:18Z</dc:date>
    </item>
    <item>
      <title>Re: regex help - only check first occurrence</title>
      <link>https://community.splunk.com/t5/Splunk-Search/regex-help-only-check-first-occurrence/m-p/123253#M33271</link>
      <description>&lt;P&gt;The string "outgoing" will always appear before the first field:value that I want to check and "username" will always appear after. I updated the sample events so they are bit more structured.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Oct 2013 22:22:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/regex-help-only-check-first-occurrence/m-p/123253#M33271</guid>
      <dc:creator>sc0tt</dc:creator>
      <dc:date>2013-10-30T22:22:13Z</dc:date>
    </item>
    <item>
      <title>Re: regex help - only check first occurrence</title>
      <link>https://community.splunk.com/t5/Splunk-Search/regex-help-only-check-first-occurrence/m-p/123254#M33272</link>
      <description>&lt;HR /&gt;

&lt;P&gt;EDIT: Updated to reflect the actual question that was asked. &lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;Well, that's still not full events, but far better. suggestion below requires that there 'outgoing' comes directly before your field/value pair, and that 'username' comes directly after (with spaces in between):&lt;/P&gt;

&lt;P&gt;props.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[your_sourcetype]
TRANSFORMS-blah = setnull, keep_val_1_2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;transforms.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[setnull]
REGEX = .
DEST_KEY = queue
FORMAT = nullQueue

[keep_val_1_2]
REGEX = outgoing\sField:(Value1|Value2)\susername:\S+
DEST_KEY = queue
FORMAT = indexQueue
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;/K&lt;/P&gt;</description>
      <pubDate>Wed, 30 Oct 2013 22:53:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/regex-help-only-check-first-occurrence/m-p/123254#M33272</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-10-30T22:53:19Z</dc:date>
    </item>
    <item>
      <title>Re: regex help - only check first occurrence</title>
      <link>https://community.splunk.com/t5/Splunk-Search/regex-help-only-check-first-occurrence/m-p/123255#M33273</link>
      <description>&lt;P&gt;didn't really read the question right. see update above.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Oct 2013 07:50:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/regex-help-only-check-first-occurrence/m-p/123255#M33273</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-10-31T07:50:11Z</dc:date>
    </item>
    <item>
      <title>Re: regex help - only check first occurrence</title>
      <link>https://community.splunk.com/t5/Splunk-Search/regex-help-only-check-first-occurrence/m-p/123256#M33274</link>
      <description>&lt;P&gt;Thanks. This works. I didn't really think of using the other fields around it. I was trying to get the regex to stop after looking at the the first field:value in case there were changes to the logs.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Oct 2013 12:41:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/regex-help-only-check-first-occurrence/m-p/123256#M33274</guid>
      <dc:creator>sc0tt</dc:creator>
      <dc:date>2013-10-31T12:41:49Z</dc:date>
    </item>
  </channel>
</rss>

