<?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 can I trim a string after a new line? in Splunk Enterprise</title>
    <link>https://community.splunk.com/t5/Splunk-Enterprise/How-can-I-trim-a-string-after-a-new-line/m-p/250861#M365</link>
    <description>&lt;P&gt;| rex field=_raw "^Message=(?[^\r\n]+)" &lt;/P&gt;

&lt;P&gt;Sorry, should be like this. &lt;/P&gt;

&lt;P&gt;Or, you can try: &lt;BR /&gt;
 | rex field=_raw "^Message=(?.+)" &lt;/P&gt;</description>
    <pubDate>Thu, 25 Aug 2016 22:34:28 GMT</pubDate>
    <dc:creator>ChrisYang</dc:creator>
    <dc:date>2016-08-25T22:34:28Z</dc:date>
    <item>
      <title>How can I trim a string after a new line?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/How-can-I-trim-a-string-after-a-new-line/m-p/250856#M360</link>
      <description>&lt;P&gt;I have a search that returns events from an error log.  I would like to do a timechart sorted by error Message.&lt;BR /&gt;&lt;BR /&gt;
However I only want to display the first line of the error message.  I would like to turn this:&lt;/P&gt;

&lt;P&gt;Message=Error approving item on orderdetail.aspx.&lt;BR /&gt;
Exception: Thread was being aborted.&lt;BR /&gt;
Stack Trace:&lt;BR /&gt;
   at System.Threading.Thread.AbortInternal()&lt;BR /&gt;
   at System.Threading.Thread.Abort(Object stateInfo)&lt;/P&gt;

&lt;P&gt;into this:&lt;BR /&gt;
Message=Error approving item on oderdetail.aspx.&lt;/P&gt;

&lt;P&gt;How can I trim the text of the Message field after the new line?&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2016 20:53:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/How-can-I-trim-a-string-after-a-new-line/m-p/250856#M360</guid>
      <dc:creator>dsapergia</dc:creator>
      <dc:date>2016-08-25T20:53:18Z</dc:date>
    </item>
    <item>
      <title>Re: How can I trim a string after a new line?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/How-can-I-trim-a-string-after-a-new-line/m-p/250857#M361</link>
      <description>&lt;P&gt;Try like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | rex field=error_message "^(?&amp;lt;error_message&amp;gt;[^\r\n]+)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Aug 2016 21:08:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/How-can-I-trim-a-string-after-a-new-line/m-p/250857#M361</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-08-25T21:08:27Z</dc:date>
    </item>
    <item>
      <title>Re: How can I trim a string after a new line?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/How-can-I-trim-a-string-after-a-new-line/m-p/250858#M362</link>
      <description>&lt;P&gt;Try this in your search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=_raw "^Message=(?&amp;lt;TrimedMessage&amp;gt;[^\n]+\n)" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then, you can display the the first line of the error message by "TrimedMessage" defined above. &lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2016 21:28:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/How-can-I-trim-a-string-after-a-new-line/m-p/250858#M362</guid>
      <dc:creator>ChrisYang</dc:creator>
      <dc:date>2016-08-25T21:28:42Z</dc:date>
    </item>
    <item>
      <title>Re: How can I trim a string after a new line?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/How-can-I-trim-a-string-after-a-new-line/m-p/250859#M363</link>
      <description>&lt;P&gt;When I do that and do timechart by TrimedMessage I only get NULL returned.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2016 21:42:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/How-can-I-trim-a-string-after-a-new-line/m-p/250859#M363</guid>
      <dc:creator>dsapergia</dc:creator>
      <dc:date>2016-08-25T21:42:00Z</dc:date>
    </item>
    <item>
      <title>Re: How can I trim a string after a new line?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/How-can-I-trim-a-string-after-a-new-line/m-p/250860#M364</link>
      <description>&lt;P&gt;That does the trick!  Thank you.  &lt;/P&gt;

&lt;P&gt;Incidentally, can you point me to some documentation about what the different variables mean in the rex expression?  Or just a quick programming -&amp;gt; English translation?&lt;/P&gt;

&lt;P&gt;I assume ? is the variable of the content of the error Message, and \r\n is a carriage return new line, but what do the ^ and + represent?&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2016 21:47:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/How-can-I-trim-a-string-after-a-new-line/m-p/250860#M364</guid>
      <dc:creator>dsapergia</dc:creator>
      <dc:date>2016-08-25T21:47:13Z</dc:date>
    </item>
    <item>
      <title>Re: How can I trim a string after a new line?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/How-can-I-trim-a-string-after-a-new-line/m-p/250861#M365</link>
      <description>&lt;P&gt;| rex field=_raw "^Message=(?[^\r\n]+)" &lt;/P&gt;

&lt;P&gt;Sorry, should be like this. &lt;/P&gt;

&lt;P&gt;Or, you can try: &lt;BR /&gt;
 | rex field=_raw "^Message=(?.+)" &lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2016 22:34:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/How-can-I-trim-a-string-after-a-new-line/m-p/250861#M365</guid>
      <dc:creator>ChrisYang</dc:creator>
      <dc:date>2016-08-25T22:34:28Z</dc:date>
    </item>
  </channel>
</rss>

