<?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: REX / REGEX question in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/REX-REGEX-question/m-p/180154#M51889</link>
    <description>&lt;P&gt;Please accept the answer to help future readers.&lt;/P&gt;</description>
    <pubDate>Wed, 28 May 2014 16:03:28 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2014-05-28T16:03:28Z</dc:date>
    <item>
      <title>REX / REGEX question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REX-REGEX-question/m-p/180143#M51878</link>
      <description>&lt;P&gt;Hi all, I am new to splunk. I am trying to extract a field from a line in a record where the field will always begin with a 2 letter state code followed by 8 additional charaters. The record also contains a two letter state field I would like to use as a variable for the extraction search, since the state will vary from record to record. Also the position of this field to be extracted will vary from record to record. I have played with multiple variations of REX and REGEX with EVAL and havent found the answer for reading a variable into the expression, or allowing the extraction position to vary across different records.&lt;/P&gt;

&lt;P&gt;Any help would be greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Wed, 28 May 2014 03:44:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REX-REGEX-question/m-p/180143#M51878</guid>
      <dc:creator>dbrown0412</dc:creator>
      <dc:date>2014-05-28T03:44:48Z</dc:date>
    </item>
    <item>
      <title>Re: REX / REGEX question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REX-REGEX-question/m-p/180144#M51879</link>
      <description>&lt;P&gt;could you please provide some samples?&lt;/P&gt;</description>
      <pubDate>Wed, 28 May 2014 06:18:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REX-REGEX-question/m-p/180144#M51879</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2014-05-28T06:18:50Z</dc:date>
    </item>
    <item>
      <title>Re: REX / REGEX question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REX-REGEX-question/m-p/180145#M51880</link>
      <description>&lt;P&gt;Hi. Sure. Here is the most recent example I have been working with.&lt;/P&gt;

&lt;P&gt;sourcetype=file  earliest=-1d@d latest=now |eval temp=STATE | rex field=comments "(?&lt;FIELD3&gt;$temp$\S{8})"| stats count as total by field1, field2,field3 | table field1,field2,field3 |sort -total|head 10&lt;/FIELD3&gt;&lt;/P&gt;

&lt;P&gt;If I remove $temp$ and use [NY] for example, I get some valid responses, but it doesn't seem to be handling the varying start position of the data in the record.&lt;/P&gt;</description>
      <pubDate>Wed, 28 May 2014 11:22:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REX-REGEX-question/m-p/180145#M51880</guid>
      <dc:creator>dbrown0412</dc:creator>
      <dc:date>2014-05-28T11:22:00Z</dc:date>
    </item>
    <item>
      <title>Re: REX / REGEX question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REX-REGEX-question/m-p/180146#M51881</link>
      <description>&lt;P&gt;Please provide some sample events (data).  At least the &lt;CODE&gt;comments&lt;/CODE&gt; field.&lt;/P&gt;</description>
      <pubDate>Wed, 28 May 2014 12:09:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REX-REGEX-question/m-p/180146#M51881</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2014-05-28T12:09:33Z</dc:date>
    </item>
    <item>
      <title>Re: REX / REGEX question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REX-REGEX-question/m-p/180147#M51882</link>
      <description>&lt;P&gt;Here is an example of what a comments field looks like. The CA12345678 is what I need to extract. The state can vary, as can the location of the data needed with the comments.&lt;/P&gt;

&lt;P&gt;FT JOE BB72649 BBB 9998372615 FT REQ ASST W/ACT ANYTHING VALID ABC,CURRENT WORDS CA12345678 NOT ALLOWING NEW BOGUS PHRASES TO GO THROUGH.ADVSD FT.FOO USELESS&lt;/P&gt;</description>
      <pubDate>Wed, 28 May 2014 13:33:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REX-REGEX-question/m-p/180147#M51882</guid>
      <dc:creator>dbrown0412</dc:creator>
      <dc:date>2014-05-28T13:33:36Z</dc:date>
    </item>
    <item>
      <title>Re: REX / REGEX question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REX-REGEX-question/m-p/180148#M51883</link>
      <description>&lt;P&gt;Will the location of CA12345678 also be changing? If not try this "\,\w+\s+\w+\s+(?P&lt;STATE&gt;[A-Za-z0-9]+)\s+"&lt;/STATE&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 May 2014 13:42:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REX-REGEX-question/m-p/180148#M51883</guid>
      <dc:creator>theouhuios</dc:creator>
      <dc:date>2014-05-28T13:42:43Z</dc:date>
    </item>
    <item>
      <title>Re: REX / REGEX question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REX-REGEX-question/m-p/180149#M51884</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   (?P&amp;lt;State&amp;gt;[A-Z]{2}[0-9]{8})\s+
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 May 2014 13:43:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REX-REGEX-question/m-p/180149#M51884</guid>
      <dc:creator>theouhuios</dc:creator>
      <dc:date>2014-05-28T13:43:07Z</dc:date>
    </item>
    <item>
      <title>Re: REX / REGEX question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REX-REGEX-question/m-p/180150#M51885</link>
      <description>&lt;P&gt;Yes, the location of CA12345678 will vary within the comments field&lt;/P&gt;</description>
      <pubDate>Wed, 28 May 2014 13:45:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REX-REGEX-question/m-p/180150#M51885</guid>
      <dc:creator>dbrown0412</dc:creator>
      <dc:date>2014-05-28T13:45:28Z</dc:date>
    </item>
    <item>
      <title>Re: REX / REGEX question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REX-REGEX-question/m-p/180151#M51886</link>
      <description>&lt;P&gt;If the location of the state varies within the comments field and the format is consistent with your example, then this should find it.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;\s+(?&amp;lt;state&amp;gt;[A-Z]{2}[0-9]{8})\s+
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 May 2014 13:50:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REX-REGEX-question/m-p/180151#M51886</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2014-05-28T13:50:43Z</dc:date>
    </item>
    <item>
      <title>Re: REX / REGEX question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REX-REGEX-question/m-p/180152#M51887</link>
      <description>&lt;P&gt;Sorry for not seeing your answer when I updated mine &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 May 2014 13:56:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REX-REGEX-question/m-p/180152#M51887</guid>
      <dc:creator>theouhuios</dc:creator>
      <dc:date>2014-05-28T13:56:36Z</dc:date>
    </item>
    <item>
      <title>Re: REX / REGEX question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REX-REGEX-question/m-p/180153#M51888</link>
      <description>&lt;P&gt;Thanks all. Changed the field to _raw and it works great&lt;/P&gt;</description>
      <pubDate>Wed, 28 May 2014 16:01:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REX-REGEX-question/m-p/180153#M51888</guid>
      <dc:creator>dbrown0412</dc:creator>
      <dc:date>2014-05-28T16:01:25Z</dc:date>
    </item>
    <item>
      <title>Re: REX / REGEX question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REX-REGEX-question/m-p/180154#M51889</link>
      <description>&lt;P&gt;Please accept the answer to help future readers.&lt;/P&gt;</description>
      <pubDate>Wed, 28 May 2014 16:03:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REX-REGEX-question/m-p/180154#M51889</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2014-05-28T16:03:28Z</dc:date>
    </item>
  </channel>
</rss>

