<?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 Replace all newlines anywhere (beginning, middle, end) on field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Replace-all-newlines-anywhere-beginning-middle-end-on-field/m-p/464827#M130971</link>
    <description>&lt;P&gt;Hello all,&lt;/P&gt;

&lt;P&gt;I have a field with data that looks like this:&lt;/P&gt;

&lt;P&gt;The process has failed. Please review.&lt;/P&gt;

&lt;P&gt;Dear Team&lt;/P&gt;

&lt;P&gt;Please assign to Team&lt;/P&gt;

&lt;P&gt;Process blah blah to blah blah &lt;/P&gt;

&lt;P&gt;Please review logs.&lt;/P&gt;

&lt;P&gt;Sincerely &lt;/P&gt;

&lt;P&gt;Support&lt;/P&gt;

&lt;P&gt;I want to remove all linebreaks like so:&lt;/P&gt;

&lt;P&gt;The process has failed. Please review blah: Dear Team Please open a new Incident and assign to Team blah Submitted from 1928389112828 blah. Please review attached logs. Sincerely, Support.&lt;/P&gt;

&lt;P&gt;I've tried sed to do it: &lt;CODE&gt;| rex mode=sed field=description "s/(\n+)//g"&lt;/CODE&gt;, but the output still has extra spaces at the beginning.&lt;BR /&gt;
I've also tried &lt;CODE&gt;trim(description)&lt;/CODE&gt; but it's giving me the same result. &lt;/P&gt;

&lt;P&gt;Any help would be appreciated. Thanks.  &lt;/P&gt;</description>
    <pubDate>Tue, 11 Feb 2020 07:39:10 GMT</pubDate>
    <dc:creator>dojiepreji</dc:creator>
    <dc:date>2020-02-11T07:39:10Z</dc:date>
    <item>
      <title>Replace all newlines anywhere (beginning, middle, end) on field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replace-all-newlines-anywhere-beginning-middle-end-on-field/m-p/464827#M130971</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;

&lt;P&gt;I have a field with data that looks like this:&lt;/P&gt;

&lt;P&gt;The process has failed. Please review.&lt;/P&gt;

&lt;P&gt;Dear Team&lt;/P&gt;

&lt;P&gt;Please assign to Team&lt;/P&gt;

&lt;P&gt;Process blah blah to blah blah &lt;/P&gt;

&lt;P&gt;Please review logs.&lt;/P&gt;

&lt;P&gt;Sincerely &lt;/P&gt;

&lt;P&gt;Support&lt;/P&gt;

&lt;P&gt;I want to remove all linebreaks like so:&lt;/P&gt;

&lt;P&gt;The process has failed. Please review blah: Dear Team Please open a new Incident and assign to Team blah Submitted from 1928389112828 blah. Please review attached logs. Sincerely, Support.&lt;/P&gt;

&lt;P&gt;I've tried sed to do it: &lt;CODE&gt;| rex mode=sed field=description "s/(\n+)//g"&lt;/CODE&gt;, but the output still has extra spaces at the beginning.&lt;BR /&gt;
I've also tried &lt;CODE&gt;trim(description)&lt;/CODE&gt; but it's giving me the same result. &lt;/P&gt;

&lt;P&gt;Any help would be appreciated. Thanks.  &lt;/P&gt;</description>
      <pubDate>Tue, 11 Feb 2020 07:39:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replace-all-newlines-anywhere-beginning-middle-end-on-field/m-p/464827#M130971</guid>
      <dc:creator>dojiepreji</dc:creator>
      <dc:date>2020-02-11T07:39:10Z</dc:date>
    </item>
    <item>
      <title>Re: Replace all newlines anywhere (beginning, middle, end) on field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replace-all-newlines-anywhere-beginning-middle-end-on-field/m-p/464828#M130972</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Use replace.&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;| makeresults &lt;BR /&gt;
| eval description = "The process has failed. Please review.&lt;/P&gt;

&lt;P&gt;Dear Team&lt;/P&gt;

&lt;P&gt;Please assign to Team&lt;/P&gt;

&lt;P&gt;Process blah blah to blah blah&lt;/P&gt;

&lt;P&gt;Please review logs.&lt;/P&gt;

&lt;P&gt;Sincerely&lt;/P&gt;

&lt;P&gt;Support" &lt;BR /&gt;
| eval description = replace(description, "\n\n", "")&lt;/P&gt;</description>
      <pubDate>Tue, 11 Feb 2020 08:55:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replace-all-newlines-anywhere-beginning-middle-end-on-field/m-p/464828#M130972</guid>
      <dc:creator>manjunathmeti</dc:creator>
      <dc:date>2020-02-11T08:55:59Z</dc:date>
    </item>
    <item>
      <title>Re: Replace all newlines anywhere (beginning, middle, end) on field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replace-all-newlines-anywhere-beginning-middle-end-on-field/m-p/464829#M130973</link>
      <description>&lt;P&gt;Did not work. Nothing happened to my field. &lt;/P&gt;</description>
      <pubDate>Tue, 11 Feb 2020 09:05:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replace-all-newlines-anywhere-beginning-middle-end-on-field/m-p/464829#M130973</guid>
      <dc:creator>dojiepreji</dc:creator>
      <dc:date>2020-02-11T09:05:13Z</dc:date>
    </item>
    <item>
      <title>Re: Replace all newlines anywhere (beginning, middle, end) on field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replace-all-newlines-anywhere-beginning-middle-end-on-field/m-p/464830#M130974</link>
      <description>&lt;P&gt;I am getting the proper result. With above query I got below value for description:&lt;/P&gt;

&lt;P&gt;&lt;EM&gt;The process has failed. Please review. Dear Team Please assign to Team Process blah blah to blah blah Please review logs. Sincerely Support&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Feb 2020 09:11:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replace-all-newlines-anywhere-beginning-middle-end-on-field/m-p/464830#M130974</guid>
      <dc:creator>manjunathmeti</dc:creator>
      <dc:date>2020-02-11T09:11:57Z</dc:date>
    </item>
    <item>
      <title>Re: Replace all newlines anywhere (beginning, middle, end) on field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replace-all-newlines-anywhere-beginning-middle-end-on-field/m-p/464831#M130975</link>
      <description>&lt;P&gt;There are multiple line breaks before the line &lt;CODE&gt;The process has failed...&lt;/CODE&gt;. This might be contributing as to why I'm not getting any changes. &lt;/P&gt;</description>
      <pubDate>Tue, 11 Feb 2020 09:31:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replace-all-newlines-anywhere-beginning-middle-end-on-field/m-p/464831#M130975</guid>
      <dc:creator>dojiepreji</dc:creator>
      <dc:date>2020-02-11T09:31:28Z</dc:date>
    </item>
    <item>
      <title>Re: Replace all newlines anywhere (beginning, middle, end) on field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replace-all-newlines-anywhere-beginning-middle-end-on-field/m-p/464832#M130976</link>
      <description>&lt;P&gt;You're close - you need to change the regex in &lt;CODE&gt;replace()&lt;/CODE&gt; from &lt;CODE&gt;"\n\n"&lt;/CODE&gt; to &lt;CODE&gt;"[\n\r\f]"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Then &lt;CODE&gt;replace()&lt;/CODE&gt; will change any form of a newline to a blank.&lt;/P&gt;

&lt;P&gt;Alternatively, you could do &lt;CODE&gt;| eval description=replace(replace(description,"[\n\r\f]"," "),"\s{2,}"," ")&lt;/CODE&gt;&lt;BR /&gt;
Which will replace newlines with a space, and then replace any sequential whitespace with a single space.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Feb 2020 15:34:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replace-all-newlines-anywhere-beginning-middle-end-on-field/m-p/464832#M130976</guid>
      <dc:creator>wmyersas</dc:creator>
      <dc:date>2020-02-11T15:34:47Z</dc:date>
    </item>
    <item>
      <title>Re: Replace all newlines anywhere (beginning, middle, end) on field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replace-all-newlines-anywhere-beginning-middle-end-on-field/m-p/464833#M130977</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval description="The process has failed. Please review.


Dear Team


Please assign to Team


Process blah blah to blah blah


Please review logs.


Sincerely


Support" 
| eval description=replace(description,"(?m)\s+"," ")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;HI, @dojiepreji&lt;BR /&gt;
try &lt;CODE&gt;(?m)&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;cf. &lt;A href="https://www.regex101.com"&gt;regex101&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Feb 2020 12:33:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replace-all-newlines-anywhere-beginning-middle-end-on-field/m-p/464833#M130977</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-02-12T12:33:45Z</dc:date>
    </item>
  </channel>
</rss>

