<?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: Regex Only Returning Partial Field Values in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Regex-Only-Returning-Partial-Field-Values/m-p/251533#M75170</link>
    <description>&lt;P&gt;Hey,&lt;/P&gt;

&lt;P&gt;instead of putting it all in one field, put it in 3 fields for street, city and country. Therefore your can just use a similar rex, but with more capturing groups:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;\"lines\":\[\"(?&amp;lt;Street&amp;gt;[^\"]+)\",\"(?&amp;lt;Town&amp;gt;[^\"]+)\",\"(?&amp;lt;Country&amp;gt;[^\"]+)\"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Remember if you use it in Splunk rex, put the " around it. After your rex you got 3 new fields, Street, Town and City. If you want you can use them as they are, or you can use an eval to combine them into one field again:&lt;/P&gt;

&lt;P&gt;...  | eval adress = 'Town'." ".'City'." ".'Country'&lt;/P&gt;

&lt;P&gt;Greetings&lt;/P&gt;

&lt;P&gt;Tom&lt;/P&gt;</description>
    <pubDate>Thu, 01 Oct 2015 13:01:30 GMT</pubDate>
    <dc:creator>tom_frotscher</dc:creator>
    <dc:date>2015-10-01T13:01:30Z</dc:date>
    <item>
      <title>Regex Only Returning Partial Field Values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Only-Returning-Partial-Field-Values/m-p/251527#M75164</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I wonder whether someone may be able to help me please.&lt;/P&gt;

&lt;P&gt;I've put together the following  regex to extract the address line from the data below.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"\"lines\":\[\"(?&amp;lt;idaAddress&amp;gt;[^\"]+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Field Data&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{"matchingDataset":{"surnames":[{"value":"Smith","verified":true}],"gender":{"value":"MALE","verified":true},"dateOfBirth":{"value":"1973-12-26","verified":true},"firstName":{"value":"John","verified":true},"addresses":[{"verified":true,"postCode":"AB1 1BC","lines":["1 A Street","A Town","GB"]}],"middleNames":{"value":"john","verified":true}},"hashedPid":"123","matchId":"_123","levelOfAssurance":"LEVEL_2"}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The problem I have is that it is only extracting the first part of the address, i.e. in the above "1 A Street" where as I would like to extract "1 A Street, A Town, GB". &lt;/P&gt;

&lt;P&gt;I'm sure that it's the back of the query which needs to change but despite trying I'm a little unsure about how to solve this.&lt;/P&gt;

&lt;P&gt;I just wondered whether someone may be able to look at this please and offer some guidance on how I can go about this.&lt;/P&gt;

&lt;P&gt;Many thanks and kindest regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2015 09:41:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Only-Returning-Partial-Field-Values/m-p/251527#M75164</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2015-10-01T09:41:12Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Only Returning Partial Field Values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Only-Returning-Partial-Field-Values/m-p/251528#M75165</link>
      <description>&lt;P&gt;Hi IRHM73,&lt;/P&gt;

&lt;P&gt;your regex is ending too early; you want to get everything until the next &lt;CODE&gt;]&lt;/CODE&gt; so use this regex:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;\"lines\":\[\"(?&amp;lt;idaAddress&amp;gt;[^\]]+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;or in a search &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search here | rex "\"lines\":\[\"(?&amp;lt;idaAddress&amp;gt;[^\]]+)" | more splunk fu
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2015 09:53:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Only-Returning-Partial-Field-Values/m-p/251528#M75165</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2015-10-01T09:53:08Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Only Returning Partial Field Values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Only-Returning-Partial-Field-Values/m-p/251529#M75166</link>
      <description>&lt;P&gt;Hi @MuS, thank my you once more for taking the time to come back to me with this and for the working solution. It feels like a very steep learning curve at the moment getting to grips with regex, but I'm sure @ll get there &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Many thanks and kind Regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2015 10:30:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Only-Returning-Partial-Field-Values/m-p/251529#M75166</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2015-10-01T10:30:30Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Only Returning Partial Field Values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Only-Returning-Partial-Field-Values/m-p/251530#M75167</link>
      <description>&lt;P&gt;Instead of just replying &lt;CODE&gt;like this:&lt;/CODE&gt; I like to provide useful answers and explain what happens &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;BR /&gt;
Just keep trying out &lt;CODE&gt;regex101.com&lt;/CODE&gt; which explains the regex very well and also try the &lt;CODE&gt;pcregextest&lt;/CODE&gt; command of Splunk &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.0/Troubleshooting/CommandlinetoolsforusewithSupport#pcregextest"&gt;http://docs.splunk.com/Documentation/Splunk/6.0/Troubleshooting/CommandlinetoolsforusewithSupport#pcregextest&lt;/A&gt; which will use Splunk's internal regex and shows what Splunk will match.&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2015 10:48:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Only-Returning-Partial-Field-Values/m-p/251530#M75167</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2015-10-01T10:48:34Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Only Returning Partial Field Values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Only-Returning-Partial-Field-Values/m-p/251531#M75168</link>
      <description>&lt;P&gt;Fair point and many thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2015 10:52:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Only-Returning-Partial-Field-Values/m-p/251531#M75168</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2015-10-01T10:52:40Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Only Returning Partial Field Values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Only-Returning-Partial-Field-Values/m-p/251532#M75169</link>
      <description>&lt;P&gt;Hi @MuS, I'm very sorry to trouble you with this again. The solution you provided does work, but unfortunately the speech marks at the end of the expression are returned in the output e.g.&lt;/P&gt;

&lt;P&gt;1 A Street"&lt;BR /&gt;
" A Town"&lt;BR /&gt;
 "GB"&lt;/P&gt;

&lt;P&gt;Is there any chance that these could be removed. As per your suggestion I've searched for solution on this forum and used regex101 to resolve this, but I just can't get it right without imbalanced ']' errors.&lt;/P&gt;

&lt;P&gt;Could you possibly let me know where I've gone wrong please?&lt;/P&gt;

&lt;P&gt;Many thanks and kind regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2015 12:19:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Only-Returning-Partial-Field-Values/m-p/251532#M75169</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2015-10-01T12:19:35Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Only Returning Partial Field Values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Only-Returning-Partial-Field-Values/m-p/251533#M75170</link>
      <description>&lt;P&gt;Hey,&lt;/P&gt;

&lt;P&gt;instead of putting it all in one field, put it in 3 fields for street, city and country. Therefore your can just use a similar rex, but with more capturing groups:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;\"lines\":\[\"(?&amp;lt;Street&amp;gt;[^\"]+)\",\"(?&amp;lt;Town&amp;gt;[^\"]+)\",\"(?&amp;lt;Country&amp;gt;[^\"]+)\"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Remember if you use it in Splunk rex, put the " around it. After your rex you got 3 new fields, Street, Town and City. If you want you can use them as they are, or you can use an eval to combine them into one field again:&lt;/P&gt;

&lt;P&gt;...  | eval adress = 'Town'." ".'City'." ".'Country'&lt;/P&gt;

&lt;P&gt;Greetings&lt;/P&gt;

&lt;P&gt;Tom&lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2015 13:01:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Only-Returning-Partial-Field-Values/m-p/251533#M75170</guid>
      <dc:creator>tom_frotscher</dc:creator>
      <dc:date>2015-10-01T13:01:30Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Only Returning Partial Field Values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Only-Returning-Partial-Field-Values/m-p/251534#M75171</link>
      <description>&lt;P&gt;Also, make sure that you click "Accept".&lt;/P&gt;</description>
      <pubDate>Fri, 02 Oct 2015 03:19:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Only-Returning-Partial-Field-Values/m-p/251534#M75171</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-10-02T03:19:30Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Only Returning Partial Field Values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Only-Returning-Partial-Field-Values/m-p/251535#M75172</link>
      <description>&lt;P&gt;Hi @Tom, thank you for coming back to me with this. I've tried the solution you kindly provided but unfortunately I receive a 'Search Parser' error.&lt;/P&gt;

&lt;P&gt;What also baffles me a little is that I ran the expression through Regex101 and it didn't show any errors?&lt;/P&gt;

&lt;P&gt;The rex line is as follows: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; rex field="detail.input-ida-request" "\"lines\":\[\"(?&amp;lt;Street&amp;gt;[^\"]+)\",\"(?&amp;lt;Town&amp;gt;[^\"]+)\",\"(?&amp;lt;Country&amp;gt;[^\"]+)\"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Many thanks and kind regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Fri, 02 Oct 2015 05:34:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Only-Returning-Partial-Field-Values/m-p/251535#M75172</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2015-10-02T05:34:47Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Only Returning Partial Field Values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Only-Returning-Partial-Field-Values/m-p/251536#M75173</link>
      <description>&lt;P&gt;You're missing the last &lt;CODE&gt;"&lt;/CODE&gt; so use it in the search this way:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search here | rex field="detail.input-ida-request" "\"lines\":\[\"(?&amp;lt;Street&amp;gt;[^\"]+)\",\"(?&amp;lt;Town&amp;gt;[^\"]+)\",\"(?&amp;lt;Country&amp;gt;[^\"]+)\"" | more splunk fu
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 02 Oct 2015 05:57:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Only-Returning-Partial-Field-Values/m-p/251536#M75173</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2015-10-02T05:57:37Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Only Returning Partial Field Values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Only-Returning-Partial-Field-Values/m-p/251537#M75174</link>
      <description>&lt;P&gt;Hi @MuS thank you very much for this, but unfortunately now  no longer returns of any of the address details.&lt;/P&gt;

&lt;P&gt;Many thanks and kind regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Fri, 02 Oct 2015 06:05:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Only-Returning-Partial-Field-Values/m-p/251537#M75174</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2015-10-02T06:05:13Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Only Returning Partial Field Values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Only-Returning-Partial-Field-Values/m-p/251538#M75175</link>
      <description>&lt;P&gt;the regex matches on regex101 without problem, but in Splunk you must put this regex inside of a starting &lt;CODE&gt;"&lt;/CODE&gt; and a end &lt;CODE&gt;"&lt;/CODE&gt; but have you tried it without the field name? So the regex is done on the &lt;CODE&gt;_raw&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search here | rex  "\"lines\":\[\"(?&amp;lt;Street&amp;gt;[^\"]+)\",\"(?&amp;lt;Town&amp;gt;[^\"]+)\",\"(?&amp;lt;Country&amp;gt;[^\"]+)\"" | table Street Town Country
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 02 Oct 2015 06:16:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Only-Returning-Partial-Field-Values/m-p/251538#M75175</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2015-10-02T06:16:19Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Only Returning Partial Field Values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Only-Returning-Partial-Field-Values/m-p/251539#M75176</link>
      <description>&lt;P&gt;Hi @MuS, unfortunately I'm still getting the same error even though I've taken the field name out. &lt;/P&gt;

&lt;P&gt;I'm very conscious  of taking up your time, so do you think me may go back to the solution you provided which was &lt;CODE&gt;"\"lines\":\[\"(?[^\]]+)"&lt;/CODE&gt; because this works and will suit my purposes better.&lt;/P&gt;

&lt;P&gt;The only problem I had with this is that it returned:&lt;/P&gt;

&lt;P&gt;1 A Street"&lt;BR /&gt;
" A Town"&lt;BR /&gt;
"GB"&lt;/P&gt;

&lt;P&gt;Where I would like please if possible:&lt;/P&gt;

&lt;P&gt;1 A Street&lt;BR /&gt;
A Town&lt;BR /&gt;
GB&lt;/P&gt;

&lt;P&gt;i.e. without the speech marks.&lt;/P&gt;

&lt;P&gt;My apologies for being a thorn in your side &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Many thanks and kind regards&lt;/P&gt;</description>
      <pubDate>Fri, 02 Oct 2015 06:30:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Only-Returning-Partial-Field-Values/m-p/251539#M75176</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2015-10-02T06:30:37Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Only Returning Partial Field Values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Only-Returning-Partial-Field-Values/m-p/251540#M75177</link>
      <description>&lt;P&gt;can you post the &lt;CODE&gt;lit search&lt;/CODE&gt; from the job inspector? the regex is not wrong; there must be some other problem.....&lt;/P&gt;</description>
      <pubDate>Fri, 02 Oct 2015 07:23:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Only-Returning-Partial-Field-Values/m-p/251540#M75177</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2015-10-02T07:23:08Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Only Returning Partial Field Values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Only-Returning-Partial-Field-Values/m-p/251541#M75178</link>
      <description>&lt;P&gt;Hi @Mus, thank you for coming back to me with this, it is greatly appreciated.&lt;/P&gt;

&lt;P&gt;I'm going to persevere with this and see if I can get this to work. I've managed to get Regex101 working with the solutions yourself and tom kindly provided and I've just written my first regex.&lt;/P&gt;

&lt;P&gt;I've accepted your answer and if I'm still unable to get this to work, I'll make another post.&lt;/P&gt;

&lt;P&gt;Once again sincere thanks for all your time trouble and patience.&lt;/P&gt;

&lt;P&gt;Have a good day and kind regards&lt;/P&gt;

&lt;P&gt;Chris &lt;/P&gt;</description>
      <pubDate>Fri, 02 Oct 2015 07:32:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Only-Returning-Partial-Field-Values/m-p/251541#M75178</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2015-10-02T07:32:02Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Only Returning Partial Field Values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Only-Returning-Partial-Field-Values/m-p/251542#M75179</link>
      <description>&lt;P&gt;No need to create a new question! I'll email you to get this working &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Oct 2015 07:45:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Only-Returning-Partial-Field-Values/m-p/251542#M75179</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2015-10-02T07:45:04Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Only Returning Partial Field Values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Only-Returning-Partial-Field-Values/m-p/251543#M75180</link>
      <description>&lt;P&gt;Many thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Oct 2015 07:47:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Only-Returning-Partial-Field-Values/m-p/251543#M75180</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2015-10-02T07:47:03Z</dc:date>
    </item>
  </channel>
</rss>

