<?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 extract two values from a string using regex? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-two-values-from-a-string-using-regex/m-p/469914#M132240</link>
    <description>&lt;P&gt;try @pc1234,&lt;BR /&gt;
&lt;STRONG&gt;Updated:&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...|rex "\[(?&amp;lt;field1&amp;gt;\w{3})\/.*\/(?&amp;lt;field2&amp;gt;\d)\]"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 02 Jun 2020 01:54:24 GMT</pubDate>
    <dc:creator>493669</dc:creator>
    <dc:date>2020-06-02T01:54:24Z</dc:date>
    <item>
      <title>How to extract two values from a string using regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-two-values-from-a-string-using-regex/m-p/469913#M132239</link>
      <description>&lt;P&gt;I'm requesting help constructing a regular expression for the following:&lt;/P&gt;
&lt;P&gt;I need to extract two values from the string below:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;[app/task/function/5]&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;field a='app' (string after first [ before first slash)
field b = '5' (value after last slash before closing]) 
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Another example is:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;[app/task/3]&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;fielda = app
fieldb= 3
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In addition, I need the extraction to fail if a string of characters is found.&lt;BR /&gt;For example, the character string to exclude is 'function':&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;[function/app/2]&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The extraction should fail since 'function' is contained in the string.&lt;/P&gt;
&lt;P&gt;Any assistance would be appreciated.&lt;/P&gt;
&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jun 2020 18:30:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-two-values-from-a-string-using-regex/m-p/469913#M132239</guid>
      <dc:creator>pc1234</dc:creator>
      <dc:date>2020-06-08T18:30:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract two values from a string using regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-two-values-from-a-string-using-regex/m-p/469914#M132240</link>
      <description>&lt;P&gt;try @pc1234,&lt;BR /&gt;
&lt;STRONG&gt;Updated:&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...|rex "\[(?&amp;lt;field1&amp;gt;\w{3})\/.*\/(?&amp;lt;field2&amp;gt;\d)\]"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 Jun 2020 01:54:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-two-values-from-a-string-using-regex/m-p/469914#M132240</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2020-06-02T01:54:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract two values from a string using regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-two-values-from-a-string-using-regex/m-p/469915#M132241</link>
      <description>&lt;P&gt;that only extracts the first value. it also doesn't address failing if a string of characters is found(see above)&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jun 2020 03:12:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-two-values-from-a-string-using-regex/m-p/469915#M132241</guid>
      <dc:creator>pc1234</dc:creator>
      <dc:date>2020-06-02T03:12:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract two values from a string using regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-two-values-from-a-string-using-regex/m-p/469916#M132242</link>
      <description>&lt;P&gt;I updated answer please try again&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jun 2020 03:22:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-two-values-from-a-string-using-regex/m-p/469916#M132242</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2020-06-02T03:22:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract two values from a string using regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-two-values-from-a-string-using-regex/m-p/469917#M132243</link>
      <description>&lt;P&gt;Hi @pc1234,&lt;BR /&gt;
use these two regexes:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex "^field\s*a\s*\=\s*(\'|\s)(?&amp;lt;fielda&amp;gt;\w+)"
| rex "^field\s*b\s*\=\s*(\'|\s)(?&amp;lt;fielda&amp;gt;\d+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can test the first at &lt;A href="https://regex101.com/r/circlS/1"&gt;https://regex101.com/r/circlS/1&lt;/A&gt; and the second at &lt;A href="https://regex101.com/r/circlS/2"&gt;https://regex101.com/r/circlS/2&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Ciao.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jun 2020 08:23:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-two-values-from-a-string-using-regex/m-p/469917#M132243</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2020-06-02T08:23:41Z</dc:date>
    </item>
  </channel>
</rss>

