<?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 How to edit my rex search to extract field values with a hyphen? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-rex-search-to-extract-field-values-with-a-hyphen/m-p/142420#M39536</link>
    <description>&lt;P&gt;Hi&lt;/P&gt;

&lt;P&gt;I am extracting a field named &lt;CODE&gt;revision&lt;/CODE&gt; from raw data and the only possible field values are 1 or 2 consecutive upper case letters or a hyphen e.g.(A,B,AC,GF, -). I tried the following, but it didn't extract the field values with a hyphen:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | rex field=_raw " Revision  (?[-A-Z]{1,2})" 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 13 Apr 2015 17:16:10 GMT</pubDate>
    <dc:creator>edrivera3</dc:creator>
    <dc:date>2015-04-13T17:16:10Z</dc:date>
    <item>
      <title>How to edit my rex search to extract field values with a hyphen?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-rex-search-to-extract-field-values-with-a-hyphen/m-p/142420#M39536</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;

&lt;P&gt;I am extracting a field named &lt;CODE&gt;revision&lt;/CODE&gt; from raw data and the only possible field values are 1 or 2 consecutive upper case letters or a hyphen e.g.(A,B,AC,GF, -). I tried the following, but it didn't extract the field values with a hyphen:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | rex field=_raw " Revision  (?[-A-Z]{1,2})" 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Apr 2015 17:16:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-rex-search-to-extract-field-values-with-a-hyphen/m-p/142420#M39536</guid>
      <dc:creator>edrivera3</dc:creator>
      <dc:date>2015-04-13T17:16:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my rex search to extract field values with a hyphen?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-rex-search-to-extract-field-values-with-a-hyphen/m-p/142421#M39537</link>
      <description>&lt;P&gt;For some reason, it doesn't appear the angle bracket with the word "revision".&lt;/P&gt;</description>
      <pubDate>Mon, 13 Apr 2015 17:19:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-rex-search-to-extract-field-values-with-a-hyphen/m-p/142421#M39537</guid>
      <dc:creator>edrivera3</dc:creator>
      <dc:date>2015-04-13T17:19:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my rex search to extract field values with a hyphen?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-rex-search-to-extract-field-values-with-a-hyphen/m-p/142422#M39538</link>
      <description>&lt;P&gt;Try this (assuming your data looks like this " some data Revision A" OR " some data Revision AB" OR " some data Revision -")&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   your base search | rex " Revision\s+(?&amp;lt;Revision&amp;gt;[-A-Z]{1,2})
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Apr 2015 17:47:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-rex-search-to-extract-field-values-with-a-hyphen/m-p/142422#M39538</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2015-04-13T17:47:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my rex search to extract field values with a hyphen?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-rex-search-to-extract-field-values-with-a-hyphen/m-p/142423#M39539</link>
      <description>&lt;P&gt;That is what I did and it's correct. My error was that I didn't noticed that there is a space before the hyphen and the single upper case letter so I changed the regex and it worked. Thanks (I am going to accept your answer!)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex " Revision (?[A-Z]{2,2}|\s\W|\s[A-Z])" 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Apr 2015 18:12:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-rex-search-to-extract-field-values-with-a-hyphen/m-p/142423#M39539</guid>
      <dc:creator>edrivera3</dc:creator>
      <dc:date>2015-04-13T18:12:23Z</dc:date>
    </item>
  </channel>
</rss>

