<?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 use the Rex command with text copied from Field Extractor? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-Rex-command-with-text-copied-from-Field-Extractor/m-p/317094#M94859</link>
    <description>&lt;P&gt;Yeeaaahh, that's highly unlikely to be the optimum rex for that.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; (?=[^P]*(?:"Required Text"|P.*"Required Text"))^(?:[^:\n]*:){7}\s+\w+\s+(?P\d+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In English - Lookahead for a first something that is a bunch of not-P followed by either "Required Text" or "a bunch of Ps and Required Text". That something can be any combination of things that aren't colons or newlines, followed by a colon, with grabbing seven of those chunks in a row, then ignore one or more spaces, one or more characters, one or more spaces again, then finally grab some decimals.&lt;/P&gt;

&lt;P&gt;Start with this - in a search, you can use as many rexes as you want to pull out individual things.  If a rex fails to match anything, then the whole rex fails.&lt;/P&gt;

&lt;P&gt;Try this - &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=_raw "\b(?&amp;lt;myfield&amp;gt;[^:\n]):\s*(?&amp;lt;myvalue&amp;gt;[^\b])" max_match=0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This assumes your data looks something like this...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  fieldname1: fieldvalue1 fieldname2:fieldvalue2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I wouldn't normally code it exactly like that, but without an example event I can't make it any more exact.&lt;/P&gt;</description>
    <pubDate>Wed, 19 Jul 2017 22:51:37 GMT</pubDate>
    <dc:creator>DalJeanis</dc:creator>
    <dc:date>2017-07-19T22:51:37Z</dc:date>
    <item>
      <title>How to use the Rex command with text copied from Field Extractor?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-Rex-command-with-text-copied-from-Field-Extractor/m-p/317092#M94857</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;

&lt;P&gt;I've used the field extractor to pull out the following field, but because the permissions are a little screwy I can't use it. How do I use this search expression with the Rex function to manually pull out what I want?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?=[^P]*(?:"Required Text"|P.*"Required Text"))^(?:[^:\n]*:){7}\s+\w+\s+(?P\d+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Apparently it's not simply &lt;CODE&gt;rex Field =_raw "(?=[^P]*(?:Port|P.*Port))^(?:[^:\n]*:){7}\s+\w+\s+(?P\d+)"&lt;/CODE&gt; but I'm new to this and not sure!&lt;/P&gt;

&lt;P&gt;Thanks for any help!&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2017 16:36:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-Rex-command-with-text-copied-from-Field-Extractor/m-p/317092#M94857</guid>
      <dc:creator>jrnastase</dc:creator>
      <dc:date>2017-07-19T16:36:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to use the Rex command with text copied from Field Extractor?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-Rex-command-with-text-copied-from-Field-Extractor/m-p/317093#M94858</link>
      <description>&lt;P&gt;Do you have sample data for us?&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2017 16:44:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-Rex-command-with-text-copied-from-Field-Extractor/m-p/317093#M94858</guid>
      <dc:creator>ddrillic</dc:creator>
      <dc:date>2017-07-19T16:44:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to use the Rex command with text copied from Field Extractor?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-Rex-command-with-text-copied-from-Field-Extractor/m-p/317094#M94859</link>
      <description>&lt;P&gt;Yeeaaahh, that's highly unlikely to be the optimum rex for that.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; (?=[^P]*(?:"Required Text"|P.*"Required Text"))^(?:[^:\n]*:){7}\s+\w+\s+(?P\d+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In English - Lookahead for a first something that is a bunch of not-P followed by either "Required Text" or "a bunch of Ps and Required Text". That something can be any combination of things that aren't colons or newlines, followed by a colon, with grabbing seven of those chunks in a row, then ignore one or more spaces, one or more characters, one or more spaces again, then finally grab some decimals.&lt;/P&gt;

&lt;P&gt;Start with this - in a search, you can use as many rexes as you want to pull out individual things.  If a rex fails to match anything, then the whole rex fails.&lt;/P&gt;

&lt;P&gt;Try this - &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=_raw "\b(?&amp;lt;myfield&amp;gt;[^:\n]):\s*(?&amp;lt;myvalue&amp;gt;[^\b])" max_match=0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This assumes your data looks something like this...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  fieldname1: fieldvalue1 fieldname2:fieldvalue2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I wouldn't normally code it exactly like that, but without an example event I can't make it any more exact.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2017 22:51:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-the-Rex-command-with-text-copied-from-Field-Extractor/m-p/317094#M94859</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-07-19T22:51:37Z</dc:date>
    </item>
  </channel>
</rss>

