<?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: Retrieve value of second matching word in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-retrieve-value-of-second-matching-word/m-p/595704#M207330</link>
    <description>&lt;P&gt;Also, remeber that by default regexes are relatively greedy (they match as much as theu can) so if you don't&amp;nbsp; specify any boundaries to matching withinyour regex, you'll have a runaway one. So, for example,&lt;/P&gt;&lt;PRE&gt;value=(?&amp;lt;value&amp;gt;.*)&lt;/PRE&gt;&lt;P&gt;will match the event&lt;/P&gt;&lt;PRE&gt;value=1, value=2, value=3&lt;/PRE&gt;&lt;P&gt;and will extract "value" field from the "1" up to the end of the string.&lt;/P&gt;&lt;P&gt;If you matched only&lt;/P&gt;&lt;PRE&gt;value=(?&amp;lt;value&amp;gt;\d+)&lt;/PRE&gt;&lt;P&gt;you'd get separate matches for each value&lt;/P&gt;</description>
    <pubDate>Thu, 28 Apr 2022 06:43:50 GMT</pubDate>
    <dc:creator>PickleRick</dc:creator>
    <dc:date>2022-04-28T06:43:50Z</dc:date>
    <item>
      <title>How retrieve value of second matching word?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-retrieve-value-of-second-matching-word/m-p/595668#M207313</link>
      <description>&lt;P&gt;In a log if there are two similar words with different value , how to retrieve value of second word using regex ?&lt;/P&gt;
&lt;P&gt;Example: "Display details of value =abc and value=def for id=1". how to display value "def" ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index=*  "Letters" |rex field=_raw max_match=0 "value=?(?&amp;lt;value2&amp;gt;[^\n]*)" |stats values(value2) as letter by id&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Above query returns&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp;"abc and value=def"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 18:03:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-retrieve-value-of-second-matching-word/m-p/595668#M207313</guid>
      <dc:creator>Aks_PC_20</dc:creator>
      <dc:date>2022-04-28T18:03:39Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve value of second matching word</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-retrieve-value-of-second-matching-word/m-p/595673#M207314</link>
      <description>&lt;P&gt;When &lt;FONT face="courier new,courier"&gt;rex&lt;/FONT&gt; finds more than one match it puts them all into a multi-valued field.&amp;nbsp; Use the mv* functions to manipulate them.&amp;nbsp; In this case, get the second word using &lt;FONT face="courier new,courier"&gt;mvindex&lt;/FONT&gt;.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval secondWord = mvindex(value2, 1)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 00:27:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-retrieve-value-of-second-matching-word/m-p/595673#M207314</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2022-04-28T00:27:13Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve value of second matching word</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-retrieve-value-of-second-matching-word/m-p/595704#M207330</link>
      <description>&lt;P&gt;Also, remeber that by default regexes are relatively greedy (they match as much as theu can) so if you don't&amp;nbsp; specify any boundaries to matching withinyour regex, you'll have a runaway one. So, for example,&lt;/P&gt;&lt;PRE&gt;value=(?&amp;lt;value&amp;gt;.*)&lt;/PRE&gt;&lt;P&gt;will match the event&lt;/P&gt;&lt;PRE&gt;value=1, value=2, value=3&lt;/PRE&gt;&lt;P&gt;and will extract "value" field from the "1" up to the end of the string.&lt;/P&gt;&lt;P&gt;If you matched only&lt;/P&gt;&lt;PRE&gt;value=(?&amp;lt;value&amp;gt;\d+)&lt;/PRE&gt;&lt;P&gt;you'd get separate matches for each value&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 06:43:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-retrieve-value-of-second-matching-word/m-p/595704#M207330</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-04-28T06:43:50Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve value of second matching word</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-retrieve-value-of-second-matching-word/m-p/595712#M207338</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/245299"&gt;@Aks_PC_20&lt;/a&gt;&amp;nbsp;- Try this query:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=* "Letters" 
| rex field=_raw max_match=0 "value=(?&amp;lt;value&amp;gt;[\S]+)"
| stats list(value) as letter by id
| eval letter=mvindex(letter,1)&lt;/LI-CODE&gt;&lt;P&gt;Please let me know if this works. Also please validate that this query works for all your examples, if not provide samples for which it does not work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this works!!&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 05:00:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-retrieve-value-of-second-matching-word/m-p/595712#M207338</guid>
      <dc:creator>VatsalJagani</dc:creator>
      <dc:date>2022-04-28T05:00:56Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve value of second matching word</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-retrieve-value-of-second-matching-word/m-p/595823#M207392</link>
      <description>&lt;P&gt;This works but if the value is displayed as value="data need to be&amp;nbsp;&lt;/P&gt;&lt;P&gt;displayed here "&lt;/P&gt;&lt;P&gt;here the value will be displayed only up to "data&amp;nbsp;need to be " and not the complete string which is in next line.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 16:49:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-retrieve-value-of-second-matching-word/m-p/595823#M207392</guid>
      <dc:creator>Aks_PC_20</dc:creator>
      <dc:date>2022-04-28T16:49:55Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve value of second matching word</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-retrieve-value-of-second-matching-word/m-p/595834#M207396</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/245299"&gt;@Aks_PC_20&lt;/a&gt;&amp;nbsp;- If your format is fixed like:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Display details of value=abc and value=def for id=1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Format: &amp;lt;some text&amp;gt; value=&amp;lt;value-1&amp;gt; and value=&amp;lt;value-2&amp;gt; for id=&amp;lt;id&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Then you can use this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=* "Letters" 
| rex field=_raw max_match=0 "value=(?&amp;lt;value1&amp;gt;.+)\s+and\s+value=(?&amp;lt;value2&amp;gt;.+)\s+for\s+id="
| stats latest(value2) as letter by id&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But to extract the proper value and to write the proper regex you first need to define the format of the events in order to know where the value is starting and ending.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this helps!!!&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 17:40:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-retrieve-value-of-second-matching-word/m-p/595834#M207396</guid>
      <dc:creator>VatsalJagani</dc:creator>
      <dc:date>2022-04-28T17:40:30Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve value of second matching word</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-retrieve-value-of-second-matching-word/m-p/595844#M207405</link>
      <description>&lt;P&gt;The value of value2 field is dynamic , each event will have different value. First query you mentioned worked but only thing is it consider the value only upto the end of line but does not consider the value which is continued in next line&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 18:29:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-retrieve-value-of-second-matching-word/m-p/595844#M207405</guid>
      <dc:creator>Aks_PC_20</dc:creator>
      <dc:date>2022-04-28T18:29:32Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve value of second matching word</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-retrieve-value-of-second-matching-word/m-p/595881#M207419</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/245299"&gt;@Aks_PC_20&lt;/a&gt;&amp;nbsp;- So does that mean in your example?&lt;/P&gt;&lt;P&gt;* value1="&lt;SPAN&gt;abc"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;* value2="def for id=1"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;(because you mentioned value2 is till the end of the line.)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If this is correct then you can use:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=* "Letters" 
| rex field=_raw max_match=0 "value=(?&amp;lt;value1&amp;gt;.+)\s+and\s+value=(?&amp;lt;value2&amp;gt;[^\n\r]+)"
| stats latest(value2) as letter by id&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this helps!!! Upvote/Karma would be appreciated!!!&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 06:01:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-retrieve-value-of-second-matching-word/m-p/595881#M207419</guid>
      <dc:creator>VatsalJagani</dc:creator>
      <dc:date>2022-04-29T06:01:23Z</dc:date>
    </item>
  </channel>
</rss>

