<?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 do you extract a string within a longer string using regex? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-extract-a-string-within-a-longer-string-using-regex/m-p/380815#M111424</link>
    <description>&lt;P&gt;&lt;CODE&gt;The suggestion did not work, I initially needed to remove the first pipe before 'makeresults' because Splunk was complaining, but afterwards nothing showed up in the results.&lt;/CODE&gt;&lt;BR /&gt;
No. that first pipe is needed for makeresults command. &lt;BR /&gt;
The makeresults command is a generating command and should be the first command in the search. Generating commands use a leading pipe character.&lt;BR /&gt;
&lt;A href="https://docs.splunk.com/Documentation/Splunk/7.2.3/SearchReference/Makeresults"&gt;https://docs.splunk.com/Documentation/Splunk/7.2.3/SearchReference/Makeresults&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;@whrg command works fine.. please check the screenshot:&lt;BR /&gt;
&lt;CODE&gt;| makeresults count=1&lt;BR /&gt;
 | eval _raw="java.lang.RuntimeException: {Here is my random string} at com.quantum.myApp bla bla bla"&lt;BR /&gt;
 | rex field=_raw "java\.lang\.RuntimeException:\s+\{(?[^\}]+)"&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/6311i4C2C478E3A879FF8/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;(PS - please accept @whrg 's answer as the accepted answer.. you can upvote this answer &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt; )&lt;/P&gt;</description>
    <pubDate>Tue, 08 Jan 2019 08:42:42 GMT</pubDate>
    <dc:creator>inventsekar</dc:creator>
    <dc:date>2019-01-08T08:42:42Z</dc:date>
    <item>
      <title>How do you extract a string within a longer string using regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-extract-a-string-within-a-longer-string-using-regex/m-p/380811#M111420</link>
      <description>&lt;P&gt;I have an event that has a key-value output, and I need to extract the random string within the long string, for example, if my output string was "java.lang.RuntimeException: {Here is my random string} at com.quantum.myApp bla bla bla .....". How can I format the output to capture my random string. I've tried replace and rex unsuccessfully but it could be I did it wrong.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Dec 2018 09:38:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-extract-a-string-within-a-longer-string-using-regex/m-p/380811#M111420</guid>
      <dc:creator>BenzionYunger</dc:creator>
      <dc:date>2018-12-26T09:38:38Z</dc:date>
    </item>
    <item>
      <title>Re: How do you extract a string within a longer string using regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-extract-a-string-within-a-longer-string-using-regex/m-p/380812#M111421</link>
      <description>&lt;P&gt;Check out this regex:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;java\.lang\.RuntimeException:\s+\{(?&amp;lt;Exception&amp;gt;[^\}]+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here you can see it in action:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults count=1
| eval _raw="java.lang.RuntimeException: {Here is my random string} at com.quantum.myApp bla bla bla"
| rex field=_raw "java\.lang\.RuntimeException:\s+\{(?&amp;lt;Exception&amp;gt;[^\}]+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now there is a new field named "Exception" with the value "Here is my random string".&lt;/P&gt;</description>
      <pubDate>Wed, 26 Dec 2018 14:27:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-extract-a-string-within-a-longer-string-using-regex/m-p/380812#M111421</guid>
      <dc:creator>whrg</dc:creator>
      <dc:date>2018-12-26T14:27:19Z</dc:date>
    </item>
    <item>
      <title>Re: How do you extract a string within a longer string using regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-extract-a-string-within-a-longer-string-using-regex/m-p/380813#M111422</link>
      <description>&lt;P&gt;hi @BenzionYunger,&lt;/P&gt;

&lt;P&gt;Did you have a chance to check out whrg's answer? If it worked, please resolve this post by approving it! If your problem is still not solved, keep us updated so that someone else can help ya. &lt;/P&gt;

&lt;P&gt;Thanks for posting!&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jan 2019 00:07:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-extract-a-string-within-a-longer-string-using-regex/m-p/380813#M111422</guid>
      <dc:creator>mstjohn_splunk</dc:creator>
      <dc:date>2019-01-08T00:07:50Z</dc:date>
    </item>
    <item>
      <title>Re: How do you extract a string within a longer string using regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-extract-a-string-within-a-longer-string-using-regex/m-p/380814#M111423</link>
      <description>&lt;P&gt;The suggestion did not work, I initially needed to remove the first pipe before 'makeresults' because Splunk was complaining, but afterwards nothing showed up in the results. My only guess is the raw expression is a randomly long string and I'm cutting if off after the first 12 words, I tried adding a wildcard at the end, but it didn't help. Maybe something needs to be refined. Here is the code I tried:&lt;BR /&gt;
 &lt;CODE&gt;index="myIndex"  makeresults count=1&lt;BR /&gt;
 | eval _raw="java.lang.RuntimeException: Sign in error message at com.quantum"&lt;BR /&gt;
 | rex field=_raw "java\.lang\.RuntimeException:\s+\{(?[^\}]+)"&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jan 2019 07:19:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-extract-a-string-within-a-longer-string-using-regex/m-p/380814#M111423</guid>
      <dc:creator>BenzionYunger</dc:creator>
      <dc:date>2019-01-08T07:19:03Z</dc:date>
    </item>
    <item>
      <title>Re: How do you extract a string within a longer string using regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-extract-a-string-within-a-longer-string-using-regex/m-p/380815#M111424</link>
      <description>&lt;P&gt;&lt;CODE&gt;The suggestion did not work, I initially needed to remove the first pipe before 'makeresults' because Splunk was complaining, but afterwards nothing showed up in the results.&lt;/CODE&gt;&lt;BR /&gt;
No. that first pipe is needed for makeresults command. &lt;BR /&gt;
The makeresults command is a generating command and should be the first command in the search. Generating commands use a leading pipe character.&lt;BR /&gt;
&lt;A href="https://docs.splunk.com/Documentation/Splunk/7.2.3/SearchReference/Makeresults"&gt;https://docs.splunk.com/Documentation/Splunk/7.2.3/SearchReference/Makeresults&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;@whrg command works fine.. please check the screenshot:&lt;BR /&gt;
&lt;CODE&gt;| makeresults count=1&lt;BR /&gt;
 | eval _raw="java.lang.RuntimeException: {Here is my random string} at com.quantum.myApp bla bla bla"&lt;BR /&gt;
 | rex field=_raw "java\.lang\.RuntimeException:\s+\{(?[^\}]+)"&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/6311i4C2C478E3A879FF8/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;(PS - please accept @whrg 's answer as the accepted answer.. you can upvote this answer &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt; )&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jan 2019 08:42:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-extract-a-string-within-a-longer-string-using-regex/m-p/380815#M111424</guid>
      <dc:creator>inventsekar</dc:creator>
      <dc:date>2019-01-08T08:42:42Z</dc:date>
    </item>
  </channel>
</rss>

