<?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 extract field from data like this? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-field-from-data-like-this/m-p/329096#M163280</link>
    <description>&lt;P&gt;hey try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?&amp;lt;location&amp;gt;[^|;]+)\|\s(?&amp;lt;degree&amp;gt;\d+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;A href="https://regex101.com/r/oPNc69/1"&gt;https://regex101.com/r/oPNc69/1&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Try this anywhere run search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults |eval tt="King's Park| 17 degrees ; Wong Chuk Hang| 16 degrees ; Ta Kwu Ling| 17 degrees ;"
|makemv tt  delim=";"|mvexpand tt|rex field=tt "(?&amp;lt;location&amp;gt;[^|;]+)\|\s(?&amp;lt;degree&amp;gt;\d+)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 27 Jan 2018 06:07:01 GMT</pubDate>
    <dc:creator>493669</dc:creator>
    <dc:date>2018-01-27T06:07:01Z</dc:date>
    <item>
      <title>How to extract field from data like this?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-field-from-data-like-this/m-p/329095#M163279</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;

&lt;P&gt;I am working on some weather RSS indexing,  some of the data look like this.&lt;/P&gt;

&lt;P&gt;King's Park| 17 degrees ; Wong Chuk Hang| 16 degrees ; Ta Kwu Ling| 17 degrees ; &lt;/P&gt;

&lt;P&gt;How can I use rex command to extract the location name (such as King's Park) and degree (such as 17)?&lt;/P&gt;

&lt;P&gt;seems regular expression need a special way to handle pipe, but I didn't find a detail solution/example on Internet.&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;

&lt;P&gt;Wallace&lt;/P&gt;</description>
      <pubDate>Sat, 27 Jan 2018 05:54:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-field-from-data-like-this/m-p/329095#M163279</guid>
      <dc:creator>cflam</dc:creator>
      <dc:date>2018-01-27T05:54:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract field from data like this?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-field-from-data-like-this/m-p/329096#M163280</link>
      <description>&lt;P&gt;hey try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?&amp;lt;location&amp;gt;[^|;]+)\|\s(?&amp;lt;degree&amp;gt;\d+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;A href="https://regex101.com/r/oPNc69/1"&gt;https://regex101.com/r/oPNc69/1&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Try this anywhere run search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults |eval tt="King's Park| 17 degrees ; Wong Chuk Hang| 16 degrees ; Ta Kwu Ling| 17 degrees ;"
|makemv tt  delim=";"|mvexpand tt|rex field=tt "(?&amp;lt;location&amp;gt;[^|;]+)\|\s(?&amp;lt;degree&amp;gt;\d+)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 27 Jan 2018 06:07:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-field-from-data-like-this/m-p/329096#M163280</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2018-01-27T06:07:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract field from data like this?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-field-from-data-like-this/m-p/329097#M163281</link>
      <description>&lt;P&gt;Try this run anywhere search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval raw="King's Park| 17 degrees,Wong Chuk Hang| 16 degrees,Ta Kwu Ling| 17 degrees"
| makemv raw delim=","
| mvexpand raw  
| rex field=raw "(?&amp;lt;location_name&amp;gt;[^\|]+)\|\s(?&amp;lt;degree&amp;gt;[^\s]+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In your environment, you should write&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=_raw  "(?&amp;lt;location_name&amp;gt;[^\|]+)\|\s(?&amp;lt;degree&amp;gt;[^\s]+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;This will work only when your event starts with &lt;CODE&gt;King's Park| 17 degrees&lt;/CODE&gt; in this format otherwise it will give you false results.&lt;/STRONG&gt;&lt;BR /&gt;
&lt;STRONG&gt;Can you give full event, so that regex can be made accurate.&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;Let me know if this helps!&lt;/P&gt;</description>
      <pubDate>Sat, 27 Jan 2018 06:19:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-field-from-data-like-this/m-p/329097#M163281</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2018-01-27T06:19:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract field from data like this?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-field-from-data-like-this/m-p/329098#M163282</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;

&lt;P&gt;Thanks so much for the swift respond and sharing!&lt;/P&gt;

&lt;P&gt;Regarding the whole event, I use RSS feed so it looks like this in Splunk.&lt;/P&gt;

&lt;P&gt;01/27/2018 14:27:38 UTC, _time="1517034458.0", author="&lt;A href="mailto:hkowm@hko.gov.hk" target="_blank"&gt;hkowm@hko.gov.hk&lt;/A&gt;", author_detail.email="&lt;A href="mailto:hkowm@hko.gov.hk" target="_blank"&gt;hkowm@hko.gov.hk&lt;/A&gt;", guidislink="False", id="&lt;A href="http://rss.weather.gov.hk/rss/CurrentWeather/20180127220200" target="_blank"&gt;http://rss.weather.gov.hk/rss/CurrentWeather/20180127220200&lt;/A&gt;", link="&lt;A href="http://www.weather.gov.hk/wxinfo/currwx/current.htm" target="_blank"&gt;http://www.weather.gov.hk/wxinfo/currwx/current.htm&lt;/A&gt;", links.0.href="&lt;A href="http://www.weather.gov.hk/wxinfo/currwx/current.htm" target="_blank"&gt;http://www.weather.gov.hk/wxinfo/currwx/current.htm&lt;/A&gt;", links.0.rel="alternate", links.0.type="text/html", published="Sat, 27 Jan 2018 14:02:00 GMT", published_parsed="2018-01-27T14:02:00Z", summary="&lt;IMG src="http://rss.weather.gov.hk/img/pic60.png" alt="" /&gt; At 10 p.m. at the Hong Kong Observatory : Air temperature : 16 degrees Celsius Relative Humidity : 84 per cent The air temperatures at other places were: Hong Kong Observatory| 16 degrees ; ---|--- King's Park| 15 degrees ; Wong Chuk Hang| 16 degrees ; Ta Kwu Ling| 16 degrees ; Lau Fau Shan| 16 degrees ; Tai Po| 16 degrees ; Sha Tin| 16 degrees ; Tuen Mun| 16 degrees ; Tseung Kwan O| 15 degrees ; Sai Kung| 16 degrees ; Cheung Chau| 16 degrees ; Chek Lap Kok| 17 degrees ; Tsing Yi| 17 degrees ; Shek Kong| 17 degrees ; Tsuen Wan Ho Koon| 15 degrees ; Tsuen Wan Shing Mun Valley| 16 degrees ; Hong Kong Park| 16 degrees ; Shau Kei Wan| 15 degrees ; Kowloon City| 16 degrees ; Happy Valley| 16 degrees ; Wong Tai Sin| 16 degrees ; Stanley| 16 degrees ; Kwun Tong| 15 degrees ; Sham Shui Po| 17 degrees ; Kai Tak Runway Park| 16 degrees ; Yuen Long Park| 17 degrees ; Tai Mei Tuk| 15 degrees . ", summary_detail.base="&lt;A href="http://rss.weather.gov.hk/rss/CurrentWeather.xml" target="_blank"&gt;http://rss.weather.gov.hk/rss/CurrentWeather.xml&lt;/A&gt;", summary_detail.language="None", summary_detail.type="text/html", summary_detail.value="&lt;IMG src="http://rss.weather.gov.hk/img/pic60.png" alt="" /&gt; At 10 p.m. at the Hong Kong Observatory : Air temperature : 16 degrees Celsius Relative Humidity : 84 per cent The air temperatures at other places were: Hong Kong Observatory| 16 degrees ; ---|--- King's Park| 15 degrees ; Wong Chuk Hang| 16 degrees ; Ta Kwu Ling| 16 degrees ; Lau Fau Shan| 16 degrees ; Tai Po| 16 degrees ; Sha Tin| 16 degrees ; Tuen Mun| 16 degrees ; Tseung Kwan O| 15 degrees ; Sai Kung| 16 degrees ; Cheung Chau| 16 degrees ; Chek Lap Kok| 17 degrees ; Tsing Yi| 17 degrees ; Shek Kong| 17 degrees ; Tsuen Wan Ho Koon| 15 degrees ; Tsuen Wan Shing Mun Valley| 16 degrees ; Hong Kong Park| 16 degrees ; Shau Kei Wan| 15 degrees ; Kowloon City| 16 degrees ; Happy Valley| 16 degrees ; Wong Tai Sin| 16 degrees ; Stanley| 16 degrees ; Kwun Tong| 15 degrees ; Sham Shui Po| 17 degrees ; Kai Tak Runway Park| 16 degrees ; Yuen Long Park| 17 degrees ; Tai Mei Tuk| 15 degrees . ", tags.0.label="None", tags.0.scheme="None", tags.0.term="R", title="Bulletin updated at 22:02 HKT 27/01/2018", title_detail.base="&lt;A href="http://rss.weather.gov.hk/rss/CurrentWeather.xml" target="_blank"&gt;http://rss.weather.gov.hk/rss/CurrentWeather.xml&lt;/A&gt;", title_detail.language="None", title_detail.type="text/plain", title_detail.value="Bulletin updated at 22:02 HKT 27/01/2018"&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:51:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-field-from-data-like-this/m-p/329098#M163282</guid>
      <dc:creator>cflam</dc:creator>
      <dc:date>2020-09-29T17:51:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract field from data like this?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-field-from-data-like-this/m-p/329099#M163283</link>
      <description>&lt;P&gt;Hi @cflam [Splunk],&lt;BR /&gt;
Try below rex:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...|rex field=_raw max_match=0 "\;(\s---\|---)*\s(?&amp;lt;location&amp;gt;[^\|]+)\|\s(?&amp;lt;degree&amp;gt;\d+)"| eval reading=mvzip(location, degree) | mvexpand reading| makemv reading delim=","| eval location=mvindex(reading, 0)     
 | eval degree=mvindex(reading, 1)|table degree location|dedup degree location
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Let me know if it works...&lt;BR /&gt;
Thanks&lt;/P&gt;</description>
      <pubDate>Sat, 27 Jan 2018 17:47:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-field-from-data-like-this/m-p/329099#M163283</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2018-01-27T17:47:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract field from data like this?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-field-from-data-like-this/m-p/329100#M163284</link>
      <description>&lt;P&gt;hey try this :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=&amp;lt;your_index&amp;gt; | rex field=_raw max_match=0 "((\s---\|---\s)|(;\s))(?&amp;lt;location_name&amp;gt;[^\|]+)\|\s(?&amp;lt;degree&amp;gt;[^\s]+)\sdegrees"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;let me know if this helps!&lt;/P&gt;</description>
      <pubDate>Sat, 27 Jan 2018 21:06:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-field-from-data-like-this/m-p/329100#M163284</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2018-01-27T21:06:00Z</dc:date>
    </item>
  </channel>
</rss>

