<?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: How to create a regex to extract data? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-data/m-p/453209#M128275</link>
    <description>&lt;P&gt;Hi @pruthvikrishnapolavarapu&lt;/P&gt;

&lt;P&gt;your regex is correct but in Splunk syntax is different and there should be at least one name group to identify what the regex is extracting.&lt;/P&gt;

&lt;P&gt;your regex throws below error:&lt;/P&gt;

&lt;P&gt;Error in 'rex' command: The regex '[(.*)SFP' does not extract anything. It should specify at least one named group. Format: (?...).&lt;/P&gt;</description>
    <pubDate>Sat, 21 Jul 2018 12:32:29 GMT</pubDate>
    <dc:creator>thambisetty</dc:creator>
    <dc:date>2018-07-21T12:32:29Z</dc:date>
    <item>
      <title>How to create a regex to extract data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-data/m-p/453206#M128272</link>
      <description>&lt;P&gt;I am new to Regex and hopefully someone can help me.  I am trying to extract data between "[" and "SFP". It doesn't matter what the data is or length of the extract as it varies.&lt;/P&gt;

&lt;P&gt;example 1: Jul 1 13:10:07 -07:00 HOSTNAME [MIC(0/2) link 0 SFP laser bias current high warning set ]&lt;BR /&gt;
example 2: Jul 10 16:08:20 -04:00 HOSTNAME [sfp-1/0/2 link 2 SFP laser bias current high warning set ]&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jul 2018 15:02:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-data/m-p/453206#M128272</guid>
      <dc:creator>donemery</dc:creator>
      <dc:date>2018-07-20T15:02:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a regex to extract data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-data/m-p/453207#M128273</link>
      <description>&lt;P&gt;| rex "\[(?&amp;lt;my_field&amp;gt;.*)SFP"&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jul 2018 15:18:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-data/m-p/453207#M128273</guid>
      <dc:creator>pradeepkumarg</dc:creator>
      <dc:date>2018-07-20T15:18:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a regex to extract data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-data/m-p/453208#M128274</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;(?&amp;lt;=\[)(.*)(?= SFP)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Jul 2018 22:36:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-data/m-p/453208#M128274</guid>
      <dc:creator>pruthvikrishnap</dc:creator>
      <dc:date>2018-07-20T22:36:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a regex to extract data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-data/m-p/453209#M128275</link>
      <description>&lt;P&gt;Hi @pruthvikrishnapolavarapu&lt;/P&gt;

&lt;P&gt;your regex is correct but in Splunk syntax is different and there should be at least one name group to identify what the regex is extracting.&lt;/P&gt;

&lt;P&gt;your regex throws below error:&lt;/P&gt;

&lt;P&gt;Error in 'rex' command: The regex '[(.*)SFP' does not extract anything. It should specify at least one named group. Format: (?...).&lt;/P&gt;</description>
      <pubDate>Sat, 21 Jul 2018 12:32:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-data/m-p/453209#M128275</guid>
      <dc:creator>thambisetty</dc:creator>
      <dc:date>2018-07-21T12:32:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a regex to extract data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-data/m-p/453210#M128276</link>
      <description>&lt;P&gt;Hi @donemery&lt;/P&gt;

&lt;P&gt;Try something like below it trims space also after 0 and before SFP. using * is not recommended:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=_raw "\[(?&amp;lt;my_field&amp;gt;[^SFP]+)\s"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The problem with * is that it will match until last occurrence of match. for example  if there are two SFP(may not be in this case in general I am talking about) in log like below&lt;/P&gt;

&lt;P&gt;Jul 1 13:10:07 -07:00 HOSTNAME [MIC(0/2) link 0 &lt;STRONG&gt;SFP&lt;/STRONG&gt; laser bias current high warning set &lt;STRONG&gt;SFP&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;result of using * is below:&lt;/P&gt;

&lt;P&gt;MIC(0/2) link 0 SFP laser bias current high warning set&lt;/P&gt;</description>
      <pubDate>Sat, 21 Jul 2018 12:55:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-data/m-p/453210#M128276</guid>
      <dc:creator>thambisetty</dc:creator>
      <dc:date>2018-07-21T12:55:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a regex to extract data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-data/m-p/453211#M128277</link>
      <description>&lt;P&gt;Like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex "\[(?&amp;lt;FieldNameHere&amp;gt;.*?)SFP"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 21 Jul 2018 17:35:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-data/m-p/453211#M128277</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2018-07-21T17:35:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a regex to extract data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-data/m-p/453212#M128278</link>
      <description>&lt;P&gt;Something like &lt;CODE&gt;.*\[(?&amp;lt;ext&amp;gt;.*)SFP.*&lt;/CODE&gt; -&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/5409iA3CA309462CF2475/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 22 Jul 2018 01:11:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-data/m-p/453212#M128278</guid>
      <dc:creator>ddrillic</dc:creator>
      <dc:date>2018-07-22T01:11:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a regex to extract data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-data/m-p/453213#M128279</link>
      <description>&lt;P&gt;Thanks for your help! One more question if I may, how would I check for XFP or SFP in a message.  The format would be identical, just the first letter could be "X" or "S". It will always be capitalized.&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jul 2018 14:57:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-data/m-p/453213#M128279</guid>
      <dc:creator>donemery</dc:creator>
      <dc:date>2018-07-23T14:57:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a regex to extract data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-data/m-p/453214#M128280</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| rex field=_raw "\[(?&amp;lt;my_field&amp;gt;.+)(SFP|XFP)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Also, I recommend that you play around with your regexes on regex101.com&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jul 2018 20:53:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-data/m-p/453214#M128280</guid>
      <dc:creator>cstump_splunk</dc:creator>
      <dc:date>2018-07-25T20:53:32Z</dc:date>
    </item>
  </channel>
</rss>

