<?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: Extract URL and text after a string in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-URL-and-text-after-a-string/m-p/645627#M223536</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/257381"&gt;@firoagni&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;you have to use two regexes because there's the possibility that a part of the event is missing, so please try this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;your_search&amp;gt;
| rex "Change:\s*\&amp;lt;a href\=\"(?&amp;lt;change_url&amp;gt;[^\"]*)\"\&amp;gt;(?&amp;lt;change&amp;gt;[^\&amp;lt;]*)"
| rex "Review: &amp;lt;a href="(?&amp;lt;review_url&amp;gt;[^\"]*)\"\&amp;gt;(?&amp;lt;review&amp;gt;[^\&amp;gt;]*)"
| table change_url change review_url review&lt;/LI-CODE&gt;&lt;P&gt;you can test these regexes at&amp;nbsp;&lt;A href="https://regex101.com/r/Vnsxl9/1" target="_blank"&gt;https://regex101.com/r/Vnsxl9/1&lt;/A&gt;&amp;nbsp;and&amp;nbsp;&lt;A href="https://regex101.com/r/Vnsxl9/2" target="_blank"&gt;https://regex101.com/r/Vnsxl9/2&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
    <pubDate>Sat, 03 Jun 2023 06:16:47 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2023-06-03T06:16:47Z</dc:date>
    <item>
      <title>How to extract URL and text after a string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-URL-and-text-after-a-string/m-p/645610#M223529</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I would like to extract fields from an unstructured data that contain multiple labels followed by its HTML href tag:&lt;/P&gt;
&lt;P&gt;Sample events:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Change: &amp;lt;a href="https://xxyyzz.com/changes/12345"&amp;gt;#12345&amp;lt;/a&amp;gt; - Review: &amp;lt;a href="https://xxyyzz.com/reviews/7890"&amp;gt;#7890&amp;lt;/a&amp;gt;

Change: &amp;lt;a href="https://xxyyzz.com/changes/1345"&amp;gt;#1345&amp;lt;/a&amp;gt; - Review: &amp;lt;a href="https://xxyyzz.com/reviews/7891"&amp;gt;#7891&amp;lt;/a&amp;gt;

Review: &amp;lt;a href="https://zzyyyxxx/reviews/205657"&amp;gt;205657&amp;lt;/a&amp;gt;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I wish to get results for the above data as follows:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;change_url                       change review_url                      review
https://xxyyzz.com/changes/12345 #12345 https://xxyyzz.com/reviews/7890 #7890 
https://xxyyzz.com/changes/1345  #1345  https://xxyyzz.com/reviews/7891 #7891
                                        https://zzyyyxxx/reviews/205657 #205657&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can someone suggest how can I use rex to obtain the above fields?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jun 2023 14:17:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-URL-and-text-after-a-string/m-p/645610#M223529</guid>
      <dc:creator>firoagni</dc:creator>
      <dc:date>2023-06-05T14:17:48Z</dc:date>
    </item>
    <item>
      <title>Re: Extract URL and text after a string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-URL-and-text-after-a-string/m-p/645621#M223533</link>
      <description>&lt;P&gt;Try&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| kv pairdelim="-" kvdelim=":\s"
| foreach Change Review
    [rex field=&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; "href=(?&amp;lt;&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;_url&amp;gt;[^\&amp;gt;]+)&amp;gt;(?&amp;lt;&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;_value&amp;gt;[^\&amp;lt;]+)"]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is an emulation that you can play with and compare with real data&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval data = mvappend("Change: &amp;lt;a href=\"https://xxyyzz.com/changes/12345\"&amp;gt;#12345&amp;lt;/a&amp;gt; - Review: &amp;lt;a href=\"https://xxyyzz.com/reviews/7890\"&amp;gt;#7890&amp;lt;/a&amp;gt;",
"Change: &amp;lt;a href=\"https://xxyyzz.com/changes/1345\"&amp;gt;#1345&amp;lt;/a&amp;gt; - Review: &amp;lt;a href=\"https://xxyyzz.com/reviews/7891\"&amp;gt;#7891&amp;lt;/a&amp;gt;",
"Review: &amp;lt;a href=\"https://zzyyyxxx/reviews/205657\"&amp;gt;205657&amp;lt;/a&amp;gt;")
| mvexpand data
| rename data AS _raw
``` data emulation above ```&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Put the two together, I get&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Change&lt;/TD&gt;&lt;TD&gt;Change_url&lt;/TD&gt;&lt;TD&gt;Review&lt;/TD&gt;&lt;TD&gt;Review_url&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;#12345&lt;/TD&gt;&lt;TD&gt;&lt;A href="https://xxyyzz.com/changes/12345" target="_blank" rel="noopener"&gt;https://xxyyzz.com/changes/12345&lt;/A&gt;&lt;/TD&gt;&lt;TD&gt;#7890&lt;/TD&gt;&lt;TD&gt;&lt;A href="https://xxyyzz.com/reviews/7890" target="_blank" rel="noopener"&gt;https://xxyyzz.com/reviews/7890&lt;/A&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;#1345&lt;/TD&gt;&lt;TD&gt;&lt;A href="https://xxyyzz.com/changes/1345" target="_blank" rel="noopener"&gt;https://xxyyzz.com/changes/1345&lt;/A&gt;&lt;/TD&gt;&lt;TD&gt;#7891&lt;/TD&gt;&lt;TD&gt;&lt;A href="https://xxyyzz.com/reviews/7891" target="_blank" rel="noopener"&gt;https://xxyyzz.com/reviews/7891&lt;/A&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;205657&lt;/TD&gt;&lt;TD&gt;&lt;A href="https://zzyyyxxx/reviews/205657" target="_blank" rel="noopener"&gt;https://zzyyyxxx/reviews/205657&lt;/A&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Sat, 03 Jun 2023 05:28:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-URL-and-text-after-a-string/m-p/645621#M223533</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-06-03T05:28:00Z</dc:date>
    </item>
    <item>
      <title>Re: Extract URL and text after a string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-URL-and-text-after-a-string/m-p/645627#M223536</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/257381"&gt;@firoagni&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;you have to use two regexes because there's the possibility that a part of the event is missing, so please try this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;your_search&amp;gt;
| rex "Change:\s*\&amp;lt;a href\=\"(?&amp;lt;change_url&amp;gt;[^\"]*)\"\&amp;gt;(?&amp;lt;change&amp;gt;[^\&amp;lt;]*)"
| rex "Review: &amp;lt;a href="(?&amp;lt;review_url&amp;gt;[^\"]*)\"\&amp;gt;(?&amp;lt;review&amp;gt;[^\&amp;gt;]*)"
| table change_url change review_url review&lt;/LI-CODE&gt;&lt;P&gt;you can test these regexes at&amp;nbsp;&lt;A href="https://regex101.com/r/Vnsxl9/1" target="_blank"&gt;https://regex101.com/r/Vnsxl9/1&lt;/A&gt;&amp;nbsp;and&amp;nbsp;&lt;A href="https://regex101.com/r/Vnsxl9/2" target="_blank"&gt;https://regex101.com/r/Vnsxl9/2&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Sat, 03 Jun 2023 06:16:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-URL-and-text-after-a-string/m-p/645627#M223536</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-06-03T06:16:47Z</dc:date>
    </item>
    <item>
      <title>Re: Extract URL and text after a string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-URL-and-text-after-a-string/m-p/645673#M223563</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/257381"&gt;@firoagni&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;good for you, see next time!&lt;/P&gt;&lt;P&gt;Ciao and happy splunking&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;&lt;P&gt;P.S.: Karma Points are appreciated by all the contributors &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 04 Jun 2023 14:25:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-URL-and-text-after-a-string/m-p/645673#M223563</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-06-04T14:25:22Z</dc:date>
    </item>
  </channel>
</rss>

