<?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 in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-extraction/m-p/184993#M53293</link>
    <description>&lt;P&gt;Then you can change the "+" to "*" to match 0 or many characters ("+" matches 1 or many):&lt;/P&gt;

&lt;P&gt;(?i)&amp;amp;account=(?P&lt;ACCOUNT&gt;[^&amp;amp;\s]*)&lt;/ACCOUNT&gt;&lt;/P&gt;

&lt;P&gt;That would produce: account=""&lt;/P&gt;

&lt;P&gt;If you wanted it to be "-", then you can use this eval:&lt;/P&gt;

&lt;P&gt;In search:&lt;BR /&gt;
| eval account=if(isNull(account),"-",account)&lt;/P&gt;

&lt;P&gt;In props.conf:&lt;/P&gt;

&lt;P&gt;EVAL-account = if(isNull(account),"-",account)&lt;/P&gt;</description>
    <pubDate>Mon, 02 Jun 2014 15:47:09 GMT</pubDate>
    <dc:creator>kyleharrison</dc:creator>
    <dc:date>2014-06-02T15:47:09Z</dc:date>
    <item>
      <title>Regex for extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-extraction/m-p/184989#M53289</link>
      <description>&lt;P&gt;Hi, &lt;/P&gt;

&lt;P&gt;i want to extract account field and i have events in 2 patterns. One where account has boundaries of @account= and right boundary as &amp;amp; as shown in event 1&lt;/P&gt;

&lt;P&gt;2nd pattern is having @account as left boundary and left boundary as space&lt;/P&gt;

&lt;P&gt;Event1 pattern is working fine but Event2 gives the whole event after account= which is  123452 HTTP/1.1" 200 1216 109354 "-" "-" "-"&lt;/P&gt;

&lt;P&gt;What should i have just to have the account value from Event2 pattern&lt;/P&gt;

&lt;P&gt;Event1&lt;BR /&gt;
 ?product=%20FILTERS%2016z20r2&amp;amp;account=12334312&amp;amp;country=US HTTP/1.1" 200 3388 218391 "-" "-" "-" "-" "-" "-" "-" "-" "-" "-" "&lt;/P&gt;

&lt;P&gt;Event2&lt;BR /&gt;
?product=2CSY1&amp;amp;account=123452 HTTP/1.1" 200 1216 109354 "-" "-" "-" &lt;/P&gt;

&lt;P&gt;Expression used:&lt;BR /&gt;
(?i)&amp;amp;account=(?P&lt;ACCOUNT&gt;[^&amp;amp;]+)(?:\s|[&amp;amp;].*)&lt;/ACCOUNT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Jun 2014 04:16:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-extraction/m-p/184989#M53289</guid>
      <dc:creator>xvxt006</dc:creator>
      <dc:date>2014-06-02T04:16:05Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-extraction/m-p/184990#M53290</link>
      <description>&lt;P&gt;This should work:&lt;BR /&gt;
(?i)&amp;amp;account=(?P&lt;ACCOUNT&gt;[^&amp;amp;\s]+)&lt;/ACCOUNT&gt;&lt;/P&gt;

&lt;P&gt;Tested ok on regex101.com with the two events you gave.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Jun 2014 05:51:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-extraction/m-p/184990#M53290</guid>
      <dc:creator>kyleharrison</dc:creator>
      <dc:date>2014-06-02T05:51:57Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-extraction/m-p/184991#M53291</link>
      <description>&lt;P&gt;Thank you. It worked.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Jun 2014 13:26:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-extraction/m-p/184991#M53291</guid>
      <dc:creator>xvxt006</dc:creator>
      <dc:date>2014-06-02T13:26:54Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-extraction/m-p/184992#M53292</link>
      <description>&lt;P&gt;One question some times it has no value in it. as shown below. i was expecting something like - in the captured values. if i want to capture that as well, can i do that? &lt;BR /&gt;
?product=%20FILTERS%2016z20r2&amp;amp;account=&amp;amp;country=US HTTP/1.1" 200 3388 218391&lt;/P&gt;</description>
      <pubDate>Mon, 02 Jun 2014 13:34:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-extraction/m-p/184992#M53292</guid>
      <dc:creator>xvxt006</dc:creator>
      <dc:date>2014-06-02T13:34:35Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-extraction/m-p/184993#M53293</link>
      <description>&lt;P&gt;Then you can change the "+" to "*" to match 0 or many characters ("+" matches 1 or many):&lt;/P&gt;

&lt;P&gt;(?i)&amp;amp;account=(?P&lt;ACCOUNT&gt;[^&amp;amp;\s]*)&lt;/ACCOUNT&gt;&lt;/P&gt;

&lt;P&gt;That would produce: account=""&lt;/P&gt;

&lt;P&gt;If you wanted it to be "-", then you can use this eval:&lt;/P&gt;

&lt;P&gt;In search:&lt;BR /&gt;
| eval account=if(isNull(account),"-",account)&lt;/P&gt;

&lt;P&gt;In props.conf:&lt;/P&gt;

&lt;P&gt;EVAL-account = if(isNull(account),"-",account)&lt;/P&gt;</description>
      <pubDate>Mon, 02 Jun 2014 15:47:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-extraction/m-p/184993#M53293</guid>
      <dc:creator>kyleharrison</dc:creator>
      <dc:date>2014-06-02T15:47:09Z</dc:date>
    </item>
  </channel>
</rss>

