<?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 Multiline regex capture and newlines in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Multiline-regex-capture-and-newlines/m-p/88427#M22624</link>
    <description>&lt;P&gt;Kevins back with more corner cases!&lt;/P&gt;

&lt;P&gt;So, I have events that will look something like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;key1=value1
key2=value2
key3=value3
key4=value4
key5=value5
something
  the
  cake
  is
  a
  lie
--------------------------
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;or like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;key1=value1
key2=value2
key3=value3
key4=value4
key5=value5
something : 
  something else
  funny
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So the kv pairs are taken care of, but I'd like to create a new event for my list of "somethings".  But there could be any number of them, they could contain any characters, and there sometimes could be a line of dashes at the end.  I thought about originally removing the dash lines altogether with the SEDCMD but they're the only consistent thing I can break events on.&lt;/P&gt;

&lt;P&gt;So a regex that works on the search path is&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=_raw "something\s*:\s(?s)(?&amp;lt;something_list&amp;gt;.*)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and in a transforms.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;REGEX = something\s*:\s(?s)(?&amp;lt;something_list&amp;gt;.*)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but the problem is it included the dashed lines.&lt;/P&gt;

&lt;P&gt;So I tried this on the search path&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=_raw "something\s*:\s(?s)(?&amp;lt;something_list&amp;gt;.*?)(:?\n-|$)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Which worked, but when I put it in the transforms it did NOT work.  &lt;/P&gt;

&lt;P&gt;Now, when I was getting the value "something_list" the first thing I noticed is that all of my caputured values were getting munged.  So the first regex would produce something_list=thecakeisalie--------------------------
 and the second something_list=thecakeisalie.  But then the second would only work from the search command and not my transforms and I'm wondering if perhaps newlines, in regexes and event creation, cause something wacky to happen inside of Splunk?&lt;/P&gt;

&lt;P&gt;Thanks,
Kevin&lt;/P&gt;</description>
    <pubDate>Sat, 13 Nov 2010 03:35:33 GMT</pubDate>
    <dc:creator>kevintelford</dc:creator>
    <dc:date>2010-11-13T03:35:33Z</dc:date>
    <item>
      <title>Multiline regex capture and newlines</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multiline-regex-capture-and-newlines/m-p/88427#M22624</link>
      <description>&lt;P&gt;Kevins back with more corner cases!&lt;/P&gt;

&lt;P&gt;So, I have events that will look something like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;key1=value1
key2=value2
key3=value3
key4=value4
key5=value5
something
  the
  cake
  is
  a
  lie
--------------------------
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;or like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;key1=value1
key2=value2
key3=value3
key4=value4
key5=value5
something : 
  something else
  funny
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So the kv pairs are taken care of, but I'd like to create a new event for my list of "somethings".  But there could be any number of them, they could contain any characters, and there sometimes could be a line of dashes at the end.  I thought about originally removing the dash lines altogether with the SEDCMD but they're the only consistent thing I can break events on.&lt;/P&gt;

&lt;P&gt;So a regex that works on the search path is&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=_raw "something\s*:\s(?s)(?&amp;lt;something_list&amp;gt;.*)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and in a transforms.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;REGEX = something\s*:\s(?s)(?&amp;lt;something_list&amp;gt;.*)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but the problem is it included the dashed lines.&lt;/P&gt;

&lt;P&gt;So I tried this on the search path&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=_raw "something\s*:\s(?s)(?&amp;lt;something_list&amp;gt;.*?)(:?\n-|$)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Which worked, but when I put it in the transforms it did NOT work.  &lt;/P&gt;

&lt;P&gt;Now, when I was getting the value "something_list" the first thing I noticed is that all of my caputured values were getting munged.  So the first regex would produce something_list=thecakeisalie--------------------------
 and the second something_list=thecakeisalie.  But then the second would only work from the search command and not my transforms and I'm wondering if perhaps newlines, in regexes and event creation, cause something wacky to happen inside of Splunk?&lt;/P&gt;

&lt;P&gt;Thanks,
Kevin&lt;/P&gt;</description>
      <pubDate>Sat, 13 Nov 2010 03:35:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multiline-regex-capture-and-newlines/m-p/88427#M22624</guid>
      <dc:creator>kevintelford</dc:creator>
      <dc:date>2010-11-13T03:35:33Z</dc:date>
    </item>
    <item>
      <title>Re: Multiline regex capture and newlines</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multiline-regex-capture-and-newlines/m-p/88428#M22625</link>
      <description>&lt;P&gt;I was gogling and found your question.&lt;/P&gt;

&lt;P&gt;I was able to get a '.' to match everything by '(.|\r)'.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Feb 2013 15:53:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multiline-regex-capture-and-newlines/m-p/88428#M22625</guid>
      <dc:creator>fk319</dc:creator>
      <dc:date>2013-02-01T15:53:38Z</dc:date>
    </item>
  </channel>
</rss>

