<?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 create a regex to extract string1 after the occurrence of string2? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-string1-after-the-occurrence-of/m-p/405783#M117312</link>
    <description>&lt;P&gt;In my logs I have something that looks like the following "string1":"string2" I would like to extract string2 as a field using string1 as a reference point for my regex.  &lt;/P&gt;</description>
    <pubDate>Wed, 27 Jun 2018 18:00:23 GMT</pubDate>
    <dc:creator>pladamsplunk</dc:creator>
    <dc:date>2018-06-27T18:00:23Z</dc:date>
    <item>
      <title>How to create a regex to extract string1 after the occurrence of string2?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-string1-after-the-occurrence-of/m-p/405783#M117312</link>
      <description>&lt;P&gt;In my logs I have something that looks like the following "string1":"string2" I would like to extract string2 as a field using string1 as a reference point for my regex.  &lt;/P&gt;</description>
      <pubDate>Wed, 27 Jun 2018 18:00:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-string1-after-the-occurrence-of/m-p/405783#M117312</guid>
      <dc:creator>pladamsplunk</dc:creator>
      <dc:date>2018-06-27T18:00:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a regex to extract string1 after the occurrence of string2?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-string1-after-the-occurrence-of/m-p/405784#M117313</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... your root search ...
| rex ‘string1”:”(?&amp;lt;fieldName&amp;gt;\w+)”’
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Note there’s a double quote followed by single quote at the end&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jun 2018 18:05:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-string1-after-the-occurrence-of/m-p/405784#M117313</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2018-06-27T18:05:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a regex to extract string1 after the occurrence of string2?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-string1-after-the-occurrence-of/m-p/405785#M117314</link>
      <description>&lt;P&gt;To make sure you get any string (except one with an embedded double quote) you should use @jkat54 's answer with a small modification:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... your root search ...
 | rex ‘string1”:”(?&amp;lt;fieldName&amp;gt;[^\"]+)”’
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That will allow for spaces, punctuation, etc.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jun 2018 20:43:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-string1-after-the-occurrence-of/m-p/405785#M117314</guid>
      <dc:creator>cpetterborg</dc:creator>
      <dc:date>2018-06-27T20:43:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a regex to extract string1 after the occurrence of string2?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-string1-after-the-occurrence-of/m-p/405786#M117315</link>
      <description>&lt;P&gt;This does not work splunk is throwing an error. However when I use jkats it doesn't work either but there is no error.&lt;/P&gt;

&lt;P&gt;The query I'm using is the following &lt;/P&gt;

&lt;P&gt;| rex ‘catalog_name”:”(?\w+)” | top fieldname&lt;/P&gt;

&lt;P&gt;where the exact example is: "catalog_name":"firmwide"&lt;/P&gt;

&lt;P&gt;i want to save firmwide into the fieldname field. &lt;/P&gt;</description>
      <pubDate>Wed, 27 Jun 2018 21:07:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-string1-after-the-occurrence-of/m-p/405786#M117315</guid>
      <dc:creator>pladamsplunk</dc:creator>
      <dc:date>2018-06-27T21:07:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a regex to extract string1 after the occurrence of string2?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-string1-after-the-occurrence-of/m-p/405787#M117316</link>
      <description>&lt;P&gt;For some reason the full regex expression isnt showing up in the comment but Im using what you wrote.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jun 2018 21:15:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-string1-after-the-occurrence-of/m-p/405787#M117316</guid>
      <dc:creator>pladamsplunk</dc:creator>
      <dc:date>2018-06-27T21:15:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a regex to extract string1 after the occurrence of string2?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-string1-after-the-occurrence-of/m-p/405788#M117317</link>
      <description>&lt;P&gt;Sorry. Here is an example "run-anywhere" search that I checked on my system:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval data="\"catalog_name\":\"firmwide\""
| rex field=data "\"catalog_name\":\"(?&amp;lt;catalog_name&amp;gt;[^\"]+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;See if this one works for you.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jun 2018 21:16:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-string1-after-the-occurrence-of/m-p/405788#M117317</guid>
      <dc:creator>cpetterborg</dc:creator>
      <dc:date>2018-06-27T21:16:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a regex to extract string1 after the occurrence of string2?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-string1-after-the-occurrence-of/m-p/405789#M117318</link>
      <description>&lt;P&gt;Looks like you missed the single quote on the end of the regex.&lt;/P&gt;

&lt;P&gt;I also don’t see the &lt;CODE&gt;&amp;lt;fieldName&amp;gt;&lt;/CODE&gt; after the ? But I think the forum stripped that because you didn’t use the 101010 button to post code.&lt;/P&gt;

&lt;P&gt;I see no reason why this wouldn’t work.  &lt;/P&gt;</description>
      <pubDate>Wed, 27 Jun 2018 21:51:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-string1-after-the-occurrence-of/m-p/405789#M117318</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2018-06-27T21:51:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a regex to extract string1 after the occurrence of string2?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-string1-after-the-occurrence-of/m-p/405790#M117319</link>
      <description>&lt;P&gt;Unless you used fieldName in the regex and then top fieldname (all lowercase).&lt;/P&gt;

&lt;P&gt;Field names are case sensitive&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jun 2018 21:53:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-string1-after-the-occurrence-of/m-p/405790#M117319</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2018-06-27T21:53:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a regex to extract string1 after the occurrence of string2?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-string1-after-the-occurrence-of/m-p/405791#M117320</link>
      <description>&lt;P&gt;Yes this works... is there a reason why when I run it on my own data it doesn't create a field? &lt;/P&gt;</description>
      <pubDate>Thu, 28 Jun 2018 13:21:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-string1-after-the-occurrence-of/m-p/405791#M117320</guid>
      <dc:creator>pladamsplunk</dc:creator>
      <dc:date>2018-06-28T13:21:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a regex to extract string1 after the occurrence of string2?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-string1-after-the-occurrence-of/m-p/405792#M117321</link>
      <description>&lt;P&gt;What doesn’t work?&lt;/P&gt;

&lt;P&gt;Does it work on 20% of your events but not 100% so you’re saying “it don’t work” or what?&lt;/P&gt;

&lt;P&gt;You could change the&lt;BR /&gt;&lt;BR /&gt;
\w+ to \S+ or .+  to expand the regex so it matches more scenarios.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jun 2018 13:32:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-string1-after-the-occurrence-of/m-p/405792#M117321</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2018-06-28T13:32:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a regex to extract string1 after the occurrence of string2?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-string1-after-the-occurrence-of/m-p/405793#M117322</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;I'm just not seeing the new field get created.
    I search for 

.....
| rex ‘catalog_name”:”(?&amp;lt;temp&amp;gt;\w+)”’ 
| top temp

and it returns no results found
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 Jun 2018 13:50:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-string1-after-the-occurrence-of/m-p/405793#M117322</guid>
      <dc:creator>pladamsplunk</dc:creator>
      <dc:date>2018-06-28T13:50:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a regex to extract string1 after the occurrence of string2?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-string1-after-the-occurrence-of/m-p/405794#M117323</link>
      <description>&lt;P&gt;Nevermind this works, I was accidently still referencing the field=data field. removing this made it functional. Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jun 2018 15:13:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-string1-after-the-occurrence-of/m-p/405794#M117323</guid>
      <dc:creator>pladamsplunk</dc:creator>
      <dc:date>2018-06-28T15:13:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a regex to extract string1 after the occurrence of string2?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-string1-after-the-occurrence-of/m-p/405795#M117324</link>
      <description>&lt;P&gt;Glad you figured it out!  We were scratching our heads!&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jun 2018 15:18:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-string1-after-the-occurrence-of/m-p/405795#M117324</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2018-06-28T15:18:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a regex to extract string1 after the occurrence of string2?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-string1-after-the-occurrence-of/m-p/405796#M117325</link>
      <description>&lt;P&gt;Sorry about that, I'm very new to using regex in splunk. &lt;/P&gt;</description>
      <pubDate>Thu, 28 Jun 2018 15:20:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-string1-after-the-occurrence-of/m-p/405796#M117325</guid>
      <dc:creator>pladamsplunk</dc:creator>
      <dc:date>2018-06-28T15:20:22Z</dc:date>
    </item>
  </channel>
</rss>

