<?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 write regex for a multivalue field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-for-a-multivalue-field/m-p/485062#M193519</link>
    <description>&lt;P&gt;| makeresults&lt;BR /&gt;
| eval my_multival="4726,4722,4726"&lt;BR /&gt;
| makemv tokenizer="([^,]+),?" my_multival&lt;/P&gt;

&lt;P&gt;this is the sample one i m using... that result id will contain data like below&lt;BR /&gt;
4726&lt;BR /&gt;
4726&lt;BR /&gt;
4722&lt;BR /&gt;
4726&lt;BR /&gt;
4726&lt;BR /&gt;
4726&lt;BR /&gt;
4722&lt;BR /&gt;
4726&lt;/P&gt;</description>
    <pubDate>Wed, 30 Sep 2020 03:41:50 GMT</pubDate>
    <dc:creator>gndivya</dc:creator>
    <dc:date>2020-09-30T03:41:50Z</dc:date>
    <item>
      <title>How to write regex for a multivalue field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-for-a-multivalue-field/m-p/485060#M193517</link>
      <description>&lt;P&gt;I have a multivalue field which is got from a stats function. using mvfind function, how to write regex for this.&lt;/P&gt;

&lt;P&gt;query...|stats list(result_id) by user&lt;/P&gt;

&lt;P&gt;result_id is a multivalue field and it contains data like&lt;/P&gt;

&lt;P&gt;r_id1&lt;BR /&gt;
r_id2&lt;BR /&gt;
r_id3&lt;BR /&gt;
r_id4&lt;/P&gt;

&lt;P&gt;I want to write a regex which matches as below&lt;BR /&gt;
r_id2&lt;BR /&gt;
r_id3&lt;/P&gt;

&lt;P&gt;but the below eval doesnt work.&lt;/P&gt;

&lt;P&gt;eval n=mvfind(result_id,"r_id2\nr_id3") &lt;BR /&gt;
OR &lt;BR /&gt;
eval n=mvfind(result_id,"r_id2\sr_id3") &lt;/P&gt;

&lt;P&gt;please help.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 03:41:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-for-a-multivalue-field/m-p/485060#M193517</guid>
      <dc:creator>gndivya</dc:creator>
      <dc:date>2020-09-30T03:41:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to write regex for a multivalue field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-for-a-multivalue-field/m-p/485061#M193518</link>
      <description>&lt;P&gt;Hi @gndivya,&lt;BR /&gt;
to help you in regex creating, could you share some example (eventually masked!)?&lt;BR /&gt;
Ciao.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jan 2020 10:16:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-for-a-multivalue-field/m-p/485061#M193518</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2020-01-20T10:16:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to write regex for a multivalue field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-for-a-multivalue-field/m-p/485062#M193519</link>
      <description>&lt;P&gt;| makeresults&lt;BR /&gt;
| eval my_multival="4726,4722,4726"&lt;BR /&gt;
| makemv tokenizer="([^,]+),?" my_multival&lt;/P&gt;

&lt;P&gt;this is the sample one i m using... that result id will contain data like below&lt;BR /&gt;
4726&lt;BR /&gt;
4726&lt;BR /&gt;
4722&lt;BR /&gt;
4726&lt;BR /&gt;
4726&lt;BR /&gt;
4726&lt;BR /&gt;
4722&lt;BR /&gt;
4726&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 03:41:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-for-a-multivalue-field/m-p/485062#M193519</guid>
      <dc:creator>gndivya</dc:creator>
      <dc:date>2020-09-30T03:41:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to write regex for a multivalue field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-for-a-multivalue-field/m-p/485063#M193520</link>
      <description>&lt;P&gt;What is your suggested output?&lt;BR /&gt;
Do you need your matching values as a new multivalue field? Or do you need the index of your matching values in your multivalue field?&lt;/P&gt;

&lt;P&gt;Maybe this can help you:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval mv="r_id1,r_id2,r_id3,r_id4"
|  makemv delim="," mv
| eval result=mvfilter(match(mv,"r_id2") OR match(mv,"r_id3"))
| eval n=if(isnotnull(mvfind(mv,"r_id2")),mvfind(mv,"r_id2"),""), n=if(isnotnull(mvfind(mv,"r_id3")),n.",".mvfind(mv,"r_id3"),"")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 Jan 2020 10:46:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-for-a-multivalue-field/m-p/485063#M193520</guid>
      <dc:creator>damann</dc:creator>
      <dc:date>2020-01-20T10:46:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to write regex for a multivalue field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-for-a-multivalue-field/m-p/485064#M193521</link>
      <description>&lt;P&gt;Verify the required result:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults count=2
| streamstats count
| eval _time=if(count=2,relative_time(_time,"-2d@d"),relative_time(_time,"-1d@d"))
| makecontinuous _time span=20m
| eval user="user_".(random() % 9 + 1)
| eval result_id="r_id".(random() % 4 + 1)
| streamstats count
| where count % 2 =1
| stats list(result_id) as result_id by user
| rex field=result_id max_match=10 "(?&amp;lt;result&amp;gt;\w+(2|3))"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hi, folks&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;How to write regex for a multivalue field?
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;CODE&gt;\w+(2|3)&lt;/CODE&gt; , this regex is.&lt;/P&gt;

&lt;P&gt;recommend:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;query...
|stats list(result_id) as result_id by user
| rex field=result_id max_match=10 "(?&amp;lt;result&amp;gt;\w+(2|3))"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How about this?   &lt;/P&gt;</description>
      <pubDate>Mon, 20 Jan 2020 11:25:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-for-a-multivalue-field/m-p/485064#M193521</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-01-20T11:25:23Z</dc:date>
    </item>
  </channel>
</rss>

