<?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 How to extract field with regex such as sentence with space in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-field-with-regex-such-as-sentence-with-space/m-p/369570#M165191</link>
    <description>&lt;P&gt;Hi regex masters,&lt;BR /&gt;
Please help me.&lt;/P&gt;

&lt;P&gt;Below are sample xml logs.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Incident Number: 151719935
    Date Of Incident: 12/02/2015 12:00:00 AM, Time of Incident: 2040
    Area Code: 17
    Area Name: Devonshire
    Road: 1782
Incident Number: 150920551
    Date Of Incident: 12/02/2015 12:00:00 AM, Time of Incident: 2000
    Area Code: 09
    Area Name: Van Nuys
    Road: 0915
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And I'd like to extract "Area Name" field then I try to use below regex.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(Area Name: )(?P&amp;lt;area_name&amp;gt;\w+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I succeed to get the value of 1st sample log but I cannot get 2nd sample log.&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/3855i18C492E806211BEF/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;How do I get not only word without space also word with space?&lt;/P&gt;</description>
    <pubDate>Tue, 14 Nov 2017 09:02:27 GMT</pubDate>
    <dc:creator>syokota_splunk</dc:creator>
    <dc:date>2017-11-14T09:02:27Z</dc:date>
    <item>
      <title>How to extract field with regex such as sentence with space</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-field-with-regex-such-as-sentence-with-space/m-p/369570#M165191</link>
      <description>&lt;P&gt;Hi regex masters,&lt;BR /&gt;
Please help me.&lt;/P&gt;

&lt;P&gt;Below are sample xml logs.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Incident Number: 151719935
    Date Of Incident: 12/02/2015 12:00:00 AM, Time of Incident: 2040
    Area Code: 17
    Area Name: Devonshire
    Road: 1782
Incident Number: 150920551
    Date Of Incident: 12/02/2015 12:00:00 AM, Time of Incident: 2000
    Area Code: 09
    Area Name: Van Nuys
    Road: 0915
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And I'd like to extract "Area Name" field then I try to use below regex.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(Area Name: )(?P&amp;lt;area_name&amp;gt;\w+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I succeed to get the value of 1st sample log but I cannot get 2nd sample log.&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/3855i18C492E806211BEF/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;How do I get not only word without space also word with space?&lt;/P&gt;</description>
      <pubDate>Tue, 14 Nov 2017 09:02:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-field-with-regex-such-as-sentence-with-space/m-p/369570#M165191</guid>
      <dc:creator>syokota_splunk</dc:creator>
      <dc:date>2017-11-14T09:02:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract field with regex such as sentence with space</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-field-with-regex-such-as-sentence-with-space/m-p/369571#M165192</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Will you please try this regex &lt;CODE&gt;(Area\sName:\s)(?P&amp;lt;area_name&amp;gt;.*)&lt;/CODE&gt; ?&lt;/P&gt;</description>
      <pubDate>Tue, 14 Nov 2017 09:06:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-field-with-regex-such-as-sentence-with-space/m-p/369571#M165192</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2017-11-14T09:06:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract field with regex such as sentence with space</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-field-with-regex-such-as-sentence-with-space/m-p/369572#M165193</link>
      <description>&lt;P&gt;Match every thing after "Area Name:" also Road and Crime Code too.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Nov 2017 09:16:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-field-with-regex-such-as-sentence-with-space/m-p/369572#M165193</guid>
      <dc:creator>syokota_splunk</dc:creator>
      <dc:date>2017-11-14T09:16:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract field with regex such as sentence with space</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-field-with-regex-such-as-sentence-with-space/m-p/369573#M165194</link>
      <description>&lt;P&gt;Try this &lt;CODE&gt;(Area\sName:\s)(?P&amp;lt;area_name&amp;gt;.*)\n&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Nov 2017 09:20:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-field-with-regex-such-as-sentence-with-space/m-p/369573#M165194</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2017-11-14T09:20:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract field with regex such as sentence with space</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-field-with-regex-such-as-sentence-with-space/m-p/369574#M165195</link>
      <description>&lt;P&gt;Same issue is happen.  &lt;/P&gt;</description>
      <pubDate>Tue, 14 Nov 2017 09:24:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-field-with-regex-such-as-sentence-with-space/m-p/369574#M165195</guid>
      <dc:creator>syokota_splunk</dc:creator>
      <dc:date>2017-11-14T09:24:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract field with regex such as sentence with space</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-field-with-regex-such-as-sentence-with-space/m-p/369575#M165196</link>
      <description>&lt;P&gt;Based on sample data if I run below search it gives me &lt;CODE&gt;Van Nuys&lt;/CODE&gt; only.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval field1="Incident Number: 150920551
     Date Of Incident: 12/02/2015 12:00:00 AM, Time of Incident: 2000
     Area Code: 09
     Area Name: Van Nuys
     Road: 0915" 
| rex field=field1 "(?s)(Area\sName:\s)(?P&amp;lt;area_name&amp;gt;.*)\n"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Nov 2017 09:37:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-field-with-regex-such-as-sentence-with-space/m-p/369575#M165196</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2017-11-14T09:37:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract field with regex such as sentence with space</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-field-with-regex-such-as-sentence-with-space/m-p/369576#M165197</link>
      <description>&lt;P&gt;You could use a pattern that says anything not a colon continued and then add the colon. &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;[^\:]+\:&lt;/CODE&gt; &lt;/P&gt;

&lt;P&gt;Then you can say not a new line continued &lt;CODE&gt;[^\n]+&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;You would want to account for the comma. Putting it together would be something like&lt;BR /&gt;
&lt;CODE&gt;[^\:]+\:[^\n]+\n[^\:]+\:[^\,]+\,[^\:]+\:[^\n]+\n&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;You wrap the parts you want to extract and label them (?PPatternForValue)&lt;/P&gt;

&lt;P&gt;The above pattern isnt complete I can finish it but it may help you to do that. Try using regex101.com. It explains what you are doing and finding&lt;/P&gt;</description>
      <pubDate>Tue, 14 Nov 2017 13:06:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-field-with-regex-such-as-sentence-with-space/m-p/369576#M165197</guid>
      <dc:creator>jgbricker</dc:creator>
      <dc:date>2017-11-14T13:06:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract field with regex such as sentence with space</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-field-with-regex-such-as-sentence-with-space/m-p/369577#M165198</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/3854i2F23CBD3D7C19DA8/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Finally I did it. It seems raw log has none "\n" code but have "\s".&lt;BR /&gt;
Thanks all! &lt;/P&gt;</description>
      <pubDate>Tue, 14 Nov 2017 13:12:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-field-with-regex-such-as-sentence-with-space/m-p/369577#M165198</guid>
      <dc:creator>syokota_splunk</dc:creator>
      <dc:date>2017-11-14T13:12:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract field with regex such as sentence with space</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-field-with-regex-such-as-sentence-with-space/m-p/369578#M165199</link>
      <description>&lt;P&gt;Yes, your search can get it. But it seems raw log has no '\n' code after "Van Nuys".&lt;BR /&gt;
Finally I figure out by your suggestion.&lt;BR /&gt;
I put the screen shot on new comment.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Nov 2017 13:13:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-field-with-regex-such-as-sentence-with-space/m-p/369578#M165199</guid>
      <dc:creator>syokota_splunk</dc:creator>
      <dc:date>2017-11-14T13:13:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract field with regex such as sentence with space</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-field-with-regex-such-as-sentence-with-space/m-p/369579#M165200</link>
      <description>&lt;P&gt;That's great, in this case you can accept your own answer so this question will be closed.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Nov 2017 13:28:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-field-with-regex-such-as-sentence-with-space/m-p/369579#M165200</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2017-11-14T13:28:36Z</dc:date>
    </item>
  </channel>
</rss>

