<?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 Search text with regex multi line mode? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Search-text-with-regex-multi-line-mode/m-p/28076#M5510</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I'm trying to search for some keywords that appear in multiple lines. I tried using regular expression in multi line mode (?m) but it does not work.&lt;/P&gt;

&lt;P&gt;In the search box, I put&lt;/P&gt;

&lt;P&gt;host=dev* | regex _raw="(?m)*POST*Can't read the image!*"&lt;/P&gt;

&lt;P&gt;I got the following error:
Error in 'SearchOperator:regex': Invalid regex '(?m)&lt;EM&gt;Can't read the image!&lt;/EM&gt;': nothing to repeat&lt;/P&gt;

&lt;P&gt;I'm on Splunk 4.0.8.&lt;/P&gt;

&lt;P&gt;Any input would be appreciated.
Thank you.&lt;/P&gt;</description>
    <pubDate>Wed, 11 Aug 2010 06:10:31 GMT</pubDate>
    <dc:creator>minalenan</dc:creator>
    <dc:date>2010-08-11T06:10:31Z</dc:date>
    <item>
      <title>Search text with regex multi line mode?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-text-with-regex-multi-line-mode/m-p/28076#M5510</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I'm trying to search for some keywords that appear in multiple lines. I tried using regular expression in multi line mode (?m) but it does not work.&lt;/P&gt;

&lt;P&gt;In the search box, I put&lt;/P&gt;

&lt;P&gt;host=dev* | regex _raw="(?m)*POST*Can't read the image!*"&lt;/P&gt;

&lt;P&gt;I got the following error:
Error in 'SearchOperator:regex': Invalid regex '(?m)&lt;EM&gt;Can't read the image!&lt;/EM&gt;': nothing to repeat&lt;/P&gt;

&lt;P&gt;I'm on Splunk 4.0.8.&lt;/P&gt;

&lt;P&gt;Any input would be appreciated.
Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Aug 2010 06:10:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-text-with-regex-multi-line-mode/m-p/28076#M5510</guid>
      <dc:creator>minalenan</dc:creator>
      <dc:date>2010-08-11T06:10:31Z</dc:date>
    </item>
    <item>
      <title>Re: Search text with regex multi line mode?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-text-with-regex-multi-line-mode/m-p/28077#M5511</link>
      <description>&lt;P&gt;This is working for me with version 4.1.4.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=apilog | regex _raw="(?m)callerAction*"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Data Example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;#### 2010-08-10 18:52:45,177
     nameSpace:     content.static.API
     subscriber:    6129045580
     callerID:      TTCOV105440648-1368613
     driver:        content.jdbc.ContentDriver
     callerAction:  MAR10446LA
     host:              10.25.50.109
     connectionResult:  SUCCESS
     Details:       Successfully updated contentDB 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would suggest an upgrade first.&lt;/P&gt;

&lt;P&gt;EDIT: Another thing that it might be throwing up on is the single quote you have in there, try escaping it:  &lt;CODE&gt;Can\'t&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Aug 2010 06:56:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-text-with-regex-multi-line-mode/m-p/28077#M5511</guid>
      <dc:creator>Lamar</dc:creator>
      <dc:date>2010-08-11T06:56:00Z</dc:date>
    </item>
    <item>
      <title>Re: Search text with regex multi line mode?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-text-with-regex-multi-line-mode/m-p/28078#M5512</link>
      <description>&lt;P&gt;It does appear that the (?m) syntax should be supported by Splunk.  But I am unclear why you need  it in this search.  If you are searching for "something" followed by "POST" followed by "something" followed by "Can't read the image!" then I think you could use&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=dev* | regex _raw=".*POST.*Can't read the image!.*"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you want the exact string *POST*Can't read the image!* then you can search for&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=dev* | regex _raw="\*POST\*Can't read the image!\*"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 11 Aug 2010 07:15:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-text-with-regex-multi-line-mode/m-p/28078#M5512</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2010-08-11T07:15:40Z</dc:date>
    </item>
    <item>
      <title>Re: Search text with regex multi line mode?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-text-with-regex-multi-line-mode/m-p/28079#M5513</link>
      <description>&lt;P&gt;Lamar, do you really need the (?m) in your regex?  I think it might work just as well without it.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Aug 2010 07:17:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-text-with-regex-multi-line-mode/m-p/28079#M5513</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2010-08-11T07:17:04Z</dc:date>
    </item>
    <item>
      <title>Re: Search text with regex multi line mode?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-text-with-regex-multi-line-mode/m-p/28080#M5514</link>
      <description>&lt;P&gt;Thanks for the answer.&lt;/P&gt;

&lt;P&gt;The word "Post" appears in a different line from "Can't read the image!" in the log files that Splunk indexed.&lt;/P&gt;

&lt;P&gt;2010-08-10 18:18:17,243 [http-8080-20 ][xxx.xxx.xxx.xxx]: INFO: POST /some_url&lt;BR /&gt;
2010-08-10 18:18:17,246 [http-8080-20 ][xxx.xxx.xxx.xxx]: DEBUG: Can't read the image!&lt;/P&gt;</description>
      <pubDate>Wed, 11 Aug 2010 08:34:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-text-with-regex-multi-line-mode/m-p/28080#M5514</guid>
      <dc:creator>minalenan</dc:creator>
      <dc:date>2010-08-11T08:34:23Z</dc:date>
    </item>
    <item>
      <title>Re: Search text with regex multi line mode?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-text-with-regex-multi-line-mode/m-p/28081#M5515</link>
      <description>&lt;P&gt;Thanks, Lamar. Unfortunately, I have no control over that. So, upgrading is not an option.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Aug 2010 08:35:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-text-with-regex-multi-line-mode/m-p/28081#M5515</guid>
      <dc:creator>minalenan</dc:creator>
      <dc:date>2010-08-11T08:35:31Z</dc:date>
    </item>
    <item>
      <title>Re: Search text with regex multi line mode?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-text-with-regex-multi-line-mode/m-p/28082#M5516</link>
      <description>&lt;P&gt;You DO NOT, in fact, need the (?m) for the regex to work.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Aug 2010 23:12:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-text-with-regex-multi-line-mode/m-p/28082#M5516</guid>
      <dc:creator>Lamar</dc:creator>
      <dc:date>2010-08-11T23:12:12Z</dc:date>
    </item>
    <item>
      <title>Re: Search text with regex multi line mode?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-text-with-regex-multi-line-mode/m-p/28083#M5517</link>
      <description>&lt;P&gt;minalenan: Additionally, reading your data below it appears that you might be consuming your data in a multiple 'event' fashion -- not a multiple 'line' fashion.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;2010-08-10 18:18:17,243 [http-8080-20 ][xxx.xxx.xxx.xxx]: INFO: POST /some_url&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;As you point out, splunk is interpreting this as two separate events and I believe you won't be able to achieve pulling this together in this fashion (If that's what you're trying to do).&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;2010-08-10 18:18:17,246 [http-8080-20 ][xxx.xxx.xxx.xxx]: DEBUG: Can't read the image!&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Moreover, if you're wanting to do a simple search of these events you might want to create a simple search that will look for both nuggets. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Something like this:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;host=dev* | search POST OR "Can't read the image!."&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Aug 2010 02:03:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-text-with-regex-multi-line-mode/m-p/28083#M5517</guid>
      <dc:creator>Lamar</dc:creator>
      <dc:date>2010-08-12T02:03:56Z</dc:date>
    </item>
    <item>
      <title>Re: Search text with regex multi line mode?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-text-with-regex-multi-line-mode/m-p/28084#M5518</link>
      <description>&lt;P&gt;Would this work for you?  The transaction command will group events with the same ip address, where the first event has POST and the second has "Can't read the image".  I arbitrarily specified that the two events should occur within 10 minutes of each other.&lt;/P&gt;

&lt;P&gt;This solution &lt;STRONG&gt;requires&lt;/STRONG&gt; that Splunk recognizes the IP address in your events.  I am assuming that the name of the IP address field is ip_addr&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=dev* (post OR "Can't read the image!") | transaction ip_addr startswith=post endswith=image maxspan=10m
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;BTW, what is the &lt;STRONG&gt;sourcetype&lt;/STRONG&gt; of these events?  If I knew the sourcetype, I might be able to make clearer suggestions.  Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 12 Aug 2010 15:18:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-text-with-regex-multi-line-mode/m-p/28084#M5518</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2010-08-12T15:18:01Z</dc:date>
    </item>
    <item>
      <title>Re: Search text with regex multi line mode?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-text-with-regex-multi-line-mode/m-p/28085#M5519</link>
      <description>&lt;P&gt;Yes, you are right. Splunk does interpret it as 2 separate events. Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Aug 2010 06:02:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-text-with-regex-multi-line-mode/m-p/28085#M5519</guid>
      <dc:creator>minalenan</dc:creator>
      <dc:date>2010-08-17T06:02:14Z</dc:date>
    </item>
    <item>
      <title>Re: Search text with regex multi line mode?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-text-with-regex-multi-line-mode/m-p/28086#M5520</link>
      <description>&lt;P&gt;This works. The sourcetype is custom for our application. I have added sourcetype to the query to narrow down the search results more. Thanks a lot!&lt;/P&gt;</description>
      <pubDate>Tue, 17 Aug 2010 07:22:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-text-with-regex-multi-line-mode/m-p/28086#M5520</guid>
      <dc:creator>minalenan</dc:creator>
      <dc:date>2010-08-17T07:22:23Z</dc:date>
    </item>
  </channel>
</rss>

