<?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 to write a regular expression to extract a long string until a group of multiple characters, and ignore if it begins or ends with double quotes? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-regular-expression-to-extract-a-long-string-until/m-p/235877#M70063</link>
    <description>&lt;P&gt;So - if a double quote exists, there is a pair of them around the message body? If no double quotes, than no "message" ? Just trying to picture it in my head. You can do a conditional pipe in the middle of the regex. Can you describe what would constitute a "message" or at least, what would precede a message? I think I can do it; just need a bit of detail first. &lt;/P&gt;</description>
    <pubDate>Tue, 22 Nov 2016 22:58:41 GMT</pubDate>
    <dc:creator>sshelly_splunk</dc:creator>
    <dc:date>2016-11-22T22:58:41Z</dc:date>
    <item>
      <title>How to write a regular expression to extract a long string until a group of multiple characters, and ignore if it begins or ends with double quotes?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-regular-expression-to-extract-a-long-string-until/m-p/235872#M70058</link>
      <description>&lt;P&gt;I am trying to extract fields out of events that are tab-delimited unless there are quotes around them. For example,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;CMSFFMHC    11/21/16 5:19 PM    "This is an error message 
    at some point in the code"  16891349    USERNAME    4   function    1234567890
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The format is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;string -tab- date/time -tab- message -tab- error_code -tab- username -tab- transaction_code -tab- function -tab- transaction_id
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Sometimes "message" contains a tab character. When it does, it's enclosed in quotes ( "message" ). I'm trying to write a regular expression to extract the message field that would:&lt;BR /&gt;
- if there is a quotation mark before message, ignore it&lt;BR /&gt;
- capture everything until a tab followed by eight digits&lt;BR /&gt;
- if there is a quotation mark at the end of the message, ignore it&lt;/P&gt;

&lt;P&gt;Further examples:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;ABCDEFG 11/21/16 11:14 PM   The request channel timed out while waiting for a reply after 00:00:17.9375000. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a long    27332747    HOST12345   5   Function1   12345678901234567890123456
ABCDEFG 11/21/16 11:13 PM   The request channel timed out while waiting for a reply after 00:00:18. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeo    16964220    HOST23456   5   Function2   23456789012345678901234567
ABCDEFG 11/21/16 5:19 PM    "
The operationFFMContactLookupfailed. 
  Error Code:[OSB-380000]
  Reason    :[[OSB-381304]Exception in HttpOutboundMessageContext.RetrieveHttpResponseWork.run: java.net.SocketTimeoutException
java.net.SocketTimeoutException
    at weblogic.net.http.Sock"  16891349    HOST34567   4   Function3   34567890123456789012345678
    ABCDEFG 11/21/16 4:06 PM    "
The operationFFMContactLookupfailed. 
  Error Code:[OSB-380000]
  Reason    :[[OSB-381304]Exception in HttpOutboundMessageContext.RetrieveHttpResponseWork.run: java.net.SocketTimeoutException
java.net.SocketTimeoutException
    at weblogic.net.http.Sock"  16865750    HOST45678   4   Function4   45678901234567890123456789
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here is my current field extraction in props.conf:&lt;/P&gt;

&lt;P&gt;EXTRACT-message=^\w+\t[^\t]+\t(?P[^\t]+)&lt;BR /&gt;
The problem is this keeps the quotation marks and stops at the tab character in the midst of the message.&lt;/P&gt;

&lt;P&gt;Can someone more versed in PCRE please lend me a hand?&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 22 Nov 2016 17:11:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-regular-expression-to-extract-a-long-string-until/m-p/235872#M70058</guid>
      <dc:creator>jwalthour</dc:creator>
      <dc:date>2016-11-22T17:11:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a regular expression to extract a long string until a group of multiple characters, and ignore if it begins or ends with double quotes?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-regular-expression-to-extract-a-long-string-until/m-p/235873#M70059</link>
      <description>&lt;P&gt;Can u post at least 2 examples of the event data with "messages" fields ?&lt;/P&gt;</description>
      <pubDate>Tue, 22 Nov 2016 17:36:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-regular-expression-to-extract-a-long-string-until/m-p/235873#M70059</guid>
      <dc:creator>sshelly_splunk</dc:creator>
      <dc:date>2016-11-22T17:36:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a regular expression to extract a long string until a group of multiple characters, and ignore if it begins or ends with double quotes?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-regular-expression-to-extract-a-long-string-until/m-p/235874#M70060</link>
      <description>&lt;P&gt;Sorry - just re-read your post. This should suffice, I think:&lt;BR /&gt;
&lt;CODE&gt;"(?P&amp;lt;message&amp;gt;.+)"&lt;/CODE&gt;&lt;BR /&gt;
 this will extract everything between double quote marks and assign the field named "message". (remove the single quote marks)&lt;BR /&gt;
If you can post the contents of your props.conf and a few more sample events, we can review and make sure it will work.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Nov 2016 17:41:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-regular-expression-to-extract-a-long-string-until/m-p/235874#M70060</guid>
      <dc:creator>sshelly_splunk</dc:creator>
      <dc:date>2016-11-22T17:41:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a regular expression to extract a long string until a group of multiple characters, and ignore if it begins or ends with double quotes?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-regular-expression-to-extract-a-long-string-until/m-p/235875#M70061</link>
      <description>&lt;P&gt;There's only one double quote in your events above. Can u edit maybe? As well, if you could include the props.conf entries and/or transforms that come into play, that would help. If you're doing a tab separated extract, you might need to get more specific using transforms since tabs can appear within  field values.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Nov 2016 18:22:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-regular-expression-to-extract-a-long-string-until/m-p/235875#M70061</guid>
      <dc:creator>sshelly_splunk</dc:creator>
      <dc:date>2016-11-22T18:22:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a regular expression to extract a long string until a group of multiple characters, and ignore if it begins or ends with double quotes?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-regular-expression-to-extract-a-long-string-until/m-p/235876#M70062</link>
      <description>&lt;P&gt;Thank you, sshelly, but your suggestion doesn't work. The regex should only consider the quotations if they are there, which most of the time they are not. More importantly, it needs to stop at the next tab, unless the tab is part of the message when it is enclosed in quotation  marks.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Nov 2016 18:53:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-regular-expression-to-extract-a-long-string-until/m-p/235876#M70062</guid>
      <dc:creator>jwalthour</dc:creator>
      <dc:date>2016-11-22T18:53:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a regular expression to extract a long string until a group of multiple characters, and ignore if it begins or ends with double quotes?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-regular-expression-to-extract-a-long-string-until/m-p/235877#M70063</link>
      <description>&lt;P&gt;So - if a double quote exists, there is a pair of them around the message body? If no double quotes, than no "message" ? Just trying to picture it in my head. You can do a conditional pipe in the middle of the regex. Can you describe what would constitute a "message" or at least, what would precede a message? I think I can do it; just need a bit of detail first. &lt;/P&gt;</description>
      <pubDate>Tue, 22 Nov 2016 22:58:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-regular-expression-to-extract-a-long-string-until/m-p/235877#M70063</guid>
      <dc:creator>sshelly_splunk</dc:creator>
      <dc:date>2016-11-22T22:58:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a regular expression to extract a long string until a group of multiple characters, and ignore if it begins or ends with double quotes?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-regular-expression-to-extract-a-long-string-until/m-p/235878#M70064</link>
      <description>&lt;P&gt;&lt;CODE&gt;\"(?P&amp;lt;message&amp;gt;[^\"]+)&lt;/CODE&gt; should give you a good start.&lt;BR /&gt;
Sometimes the rex can be funny with quote marks, you may end up having to add in multiples e.g. \" or \\"&lt;/P&gt;</description>
      <pubDate>Tue, 22 Nov 2016 23:02:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-regular-expression-to-extract-a-long-string-until/m-p/235878#M70064</guid>
      <dc:creator>mrgibbon</dc:creator>
      <dc:date>2016-11-22T23:02:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a regular expression to extract a long string until a group of multiple characters, and ignore if it begins or ends with double quotes?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-regular-expression-to-extract-a-long-string-until/m-p/235879#M70065</link>
      <description>&lt;P&gt;How about something like this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;^[^\t]+\t[^\t]+\t\"?(?&amp;lt;message&amp;gt;[^\"]+)\"?\t\d{8}\t
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Nov 2016 01:35:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-regular-expression-to-extract-a-long-string-until/m-p/235879#M70065</guid>
      <dc:creator>maciep</dc:creator>
      <dc:date>2016-11-23T01:35:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a regular expression to extract a long string until a group of multiple characters, and ignore if it begins or ends with double quotes?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-regular-expression-to-extract-a-long-string-until/m-p/235880#M70066</link>
      <description>&lt;P&gt;See if this regex suffices which will captureall the cases you mentioned:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;^(?&amp;lt;first&amp;gt;[^\t]+)\t(?&amp;lt;second&amp;gt;[^\t]+)(\t|\t")(?&amp;lt;message&amp;gt;(.*))("\t|\t)\d{8}\t
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;See extraction at work &lt;A href="https://regex101.com/r/4hyefK/1"&gt;here&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Nov 2016 05:31:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-regular-expression-to-extract-a-long-string-until/m-p/235880#M70066</guid>
      <dc:creator>gokadroid</dc:creator>
      <dc:date>2016-11-23T05:31:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a regular expression to extract a long string until a group of multiple characters, and ignore if it begins or ends with double quotes?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-regular-expression-to-extract-a-long-string-until/m-p/235881#M70067</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex "(?ms)^(?:[^\t]*\t){2}\"?(?&amp;lt;message&amp;gt;.+)\"?\t(?:[^\t]*\t){4}[^\t]*$"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 11 Mar 2017 21:09:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-regular-expression-to-extract-a-long-string-until/m-p/235881#M70067</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-03-11T21:09:59Z</dc:date>
    </item>
  </channel>
</rss>

