<?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 edit my regular expression to include a space in order for Splunk to extract data? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-edit-my-regular-expression-to-include-a-space-in-order/m-p/268677#M51546</link>
    <description>&lt;P&gt;I am assuming from your sample data that you are trying to extract &lt;CODE&gt;AB11AB&lt;/CODE&gt; from &lt;CODE&gt;"postcode":"AB11AB"&lt;/CODE&gt; hence I have written regex to capture &lt;STRONG&gt;POSTCODE&lt;/STRONG&gt; as string between &lt;CODE&gt;"postcode":"&lt;/CODE&gt;&lt;STRONG&gt;POSTCODE&lt;/STRONG&gt; &lt;CODE&gt;"&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your query to return events
| rex field=_raw "\"postcode\"\:\"(?&amp;lt;myPostcode&amp;gt;[^\"]+)\""
| table myPostcode
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;A href="https://regex101.com/r/jPPrSI/4"&gt;See regex in action here&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;In case you want to go &lt;CODE&gt;json&lt;/CODE&gt; way, try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your query to return json events
 | spath output=myPostcode path=postcode
 | table postcode, myPostcode
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 08 Dec 2016 08:16:57 GMT</pubDate>
    <dc:creator>gokadroid</dc:creator>
    <dc:date>2016-12-08T08:16:57Z</dc:date>
    <item>
      <title>How to edit my regular expression to include a space in order for Splunk to extract data?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-edit-my-regular-expression-to-include-a-space-in-order/m-p/268676#M51545</link>
      <description>&lt;P&gt;Hi, I wonder whether someone could help me please.&lt;/P&gt;

&lt;P&gt;I'm trying to create a Splunk regular expression to extract the postcode from the sample as shown below.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{"line1":"1 THE STREET","line2":"TOWN","line3":"CITY","line4":null,"postcode":"AB1 1AB","country":"GREAT BRITAIN","startDate":944697600000,"type":"Residential"}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm using Regex101 and in this I can create the following which extracts the data:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;\"postcode\"\:\"(?[^\.]{0,7})\"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, when I run this in Splunk, it doesn't extract the data.&lt;/P&gt;

&lt;P&gt;I think it may have something to do with the space between the two elements of the postcode, but could someone please look at this and let me know where I've gone wrong.&lt;/P&gt;

&lt;P&gt;Many thanks and kind regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2016 08:08:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-edit-my-regular-expression-to-include-a-space-in-order/m-p/268676#M51545</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2016-12-08T08:08:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my regular expression to include a space in order for Splunk to extract data?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-edit-my-regular-expression-to-include-a-space-in-order/m-p/268677#M51546</link>
      <description>&lt;P&gt;I am assuming from your sample data that you are trying to extract &lt;CODE&gt;AB11AB&lt;/CODE&gt; from &lt;CODE&gt;"postcode":"AB11AB"&lt;/CODE&gt; hence I have written regex to capture &lt;STRONG&gt;POSTCODE&lt;/STRONG&gt; as string between &lt;CODE&gt;"postcode":"&lt;/CODE&gt;&lt;STRONG&gt;POSTCODE&lt;/STRONG&gt; &lt;CODE&gt;"&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your query to return events
| rex field=_raw "\"postcode\"\:\"(?&amp;lt;myPostcode&amp;gt;[^\"]+)\""
| table myPostcode
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;A href="https://regex101.com/r/jPPrSI/4"&gt;See regex in action here&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;In case you want to go &lt;CODE&gt;json&lt;/CODE&gt; way, try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your query to return json events
 | spath output=myPostcode path=postcode
 | table postcode, myPostcode
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Dec 2016 08:16:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-edit-my-regular-expression-to-include-a-space-in-order/m-p/268677#M51546</guid>
      <dc:creator>gokadroid</dc:creator>
      <dc:date>2016-12-08T08:16:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my regular expression to include a space in order for Splunk to extract data?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-edit-my-regular-expression-to-include-a-space-in-order/m-p/268678#M51547</link>
      <description>&lt;P&gt;Hi thank you for coming back to me with this, but it doesn't work. I've looked at our regex101 example and it doesn't include the space between the two elements of the postcode. I think that may be the issue.&lt;/P&gt;

&lt;P&gt;Many thanks and kind regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2016 08:19:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-edit-my-regular-expression-to-include-a-space-in-order/m-p/268678#M51547</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2016-12-08T08:19:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my regular expression to include a space in order for Splunk to extract data?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-edit-my-regular-expression-to-include-a-space-in-order/m-p/268679#M51548</link>
      <description>&lt;P&gt;Did you see the link I posted...Regex is to capture everything between &lt;CODE&gt;"postcode":"&lt;/CODE&gt; and ending &lt;CODE&gt;"&lt;/CODE&gt;. So even if there are spaces in between it will capture. Can you please paste the sample postcode, an actual event containing this postcode.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2016 08:22:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-edit-my-regular-expression-to-include-a-space-in-order/m-p/268679#M51548</guid>
      <dc:creator>gokadroid</dc:creator>
      <dc:date>2016-12-08T08:22:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my regular expression to include a space in order for Splunk to extract data?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-edit-my-regular-expression-to-include-a-space-in-order/m-p/268680#M51549</link>
      <description>&lt;P&gt;Hi @gokadroid, thank you for coming back to me and my sincere apologies because my sample didn't show a space between two elements of the postcode. I've now changed this.&lt;/P&gt;

&lt;P&gt;So this is where I have the problem, both solutions don't extract the postcode data. &lt;/P&gt;

&lt;P&gt;Your solution works great in regex101 for postcodes with and without a space, but doesn't in Splunk.&lt;/P&gt;

&lt;P&gt;Many thanks and kind regards &lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2016 08:32:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-edit-my-regular-expression-to-include-a-space-in-order/m-p/268680#M51549</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2016-12-08T08:32:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my regular expression to include a space in order for Splunk to extract data?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-edit-my-regular-expression-to-include-a-space-in-order/m-p/268681#M51550</link>
      <description>&lt;P&gt;Where in Splunk are you using it? Are you writing it like the SPL query I have written?&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2016 08:36:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-edit-my-regular-expression-to-include-a-space-in-order/m-p/268681#M51550</guid>
      <dc:creator>gokadroid</dc:creator>
      <dc:date>2016-12-08T08:36:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my regular expression to include a space in order for Splunk to extract data?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-edit-my-regular-expression-to-include-a-space-in-order/m-p/268682#M51551</link>
      <description>&lt;P&gt;Hi @gokadroid, thank you for this.&lt;/P&gt;

&lt;P&gt;My query line for this is as follows:&lt;/P&gt;

&lt;P&gt;| rex field=detail.responseMessage ""&lt;/P&gt;

&lt;P&gt;I then use the regex name, in this case  to display in a table.&lt;/P&gt;

&lt;P&gt;Kind Regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2016 08:46:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-edit-my-regular-expression-to-include-a-space-in-order/m-p/268682#M51551</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2016-12-08T08:46:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my regular expression to include a space in order for Splunk to extract data?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-edit-my-regular-expression-to-include-a-space-in-order/m-p/268683#M51552</link>
      <description>&lt;P&gt;Can you try to use the &lt;CODE&gt;field=_raw&lt;/CODE&gt; rather than &lt;CODE&gt;field=detail.responseMessage&lt;/CODE&gt;?&lt;/P&gt;

&lt;P&gt;If your data is json then try to use &lt;CODE&gt;spath&lt;/CODE&gt; which can also assist like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your query to return json events
| spath output=myPostcode path=postcode
| table postcode, myPostcode
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Dec 2016 08:49:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-edit-my-regular-expression-to-include-a-space-in-order/m-p/268683#M51552</guid>
      <dc:creator>gokadroid</dc:creator>
      <dc:date>2016-12-08T08:49:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my regular expression to include a space in order for Splunk to extract data?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-edit-my-regular-expression-to-include-a-space-in-order/m-p/268684#M51553</link>
      <description>&lt;P&gt;Hi, this is very strange.&lt;/P&gt;

&lt;P&gt;Because I've found that the  field is extracting the data as an "interesting filed", but when I try to use this in a table, the column returns blank values.&lt;/P&gt;

&lt;P&gt;Kind Regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2016 09:10:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-edit-my-regular-expression-to-include-a-space-in-order/m-p/268684#M51553</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2016-12-08T09:10:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my regular expression to include a space in order for Splunk to extract data?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-edit-my-regular-expression-to-include-a-space-in-order/m-p/268685#M51554</link>
      <description>&lt;P&gt;Hi @gokadroid.&lt;/P&gt;

&lt;P&gt;I've cracked it.  I discovered because the field was missing from a "stats values) row further down in the query, it wasn't appearing in the table.&lt;/P&gt;

&lt;P&gt;My sincere apologies for messing you around and many thanks for your help.&lt;/P&gt;

&lt;P&gt;Kind Regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2016 09:17:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-edit-my-regular-expression-to-include-a-space-in-order/m-p/268685#M51554</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2016-12-08T09:17:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my regular expression to include a space in order for Splunk to extract data?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-edit-my-regular-expression-to-include-a-space-in-order/m-p/268686#M51555</link>
      <description>&lt;P&gt;I've deleted my answer as I just noticed there was already one suggesting spath.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2016 09:21:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-edit-my-regular-expression-to-include-a-space-in-order/m-p/268686#M51555</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2016-12-08T09:21:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my regular expression to include a space in order for Splunk to extract data?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-edit-my-regular-expression-to-include-a-space-in-order/m-p/268687#M51556</link>
      <description>&lt;P&gt;That's fine @IRHM73. We all are here to help each other.&lt;BR /&gt;
Let me get rid of all the back and forth comments and streamline the original answer with the json bit, in case someone else in future needs to refer it. &lt;/P&gt;

&lt;P&gt;Its all well if it works out well for you!!&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2016 09:23:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-edit-my-regular-expression-to-include-a-space-in-order/m-p/268687#M51556</guid>
      <dc:creator>gokadroid</dc:creator>
      <dc:date>2016-12-08T09:23:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my regular expression to include a space in order for Splunk to extract data?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-edit-my-regular-expression-to-include-a-space-in-order/m-p/268688#M51557</link>
      <description>&lt;P&gt;Ok, once again, sincere thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2016 09:25:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-edit-my-regular-expression-to-include-a-space-in-order/m-p/268688#M51557</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2016-12-08T09:25:52Z</dc:date>
    </item>
  </channel>
</rss>

