<?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 do I use my regular expression to extract values in a column? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-my-regular-expression-to-extract-values-in-a-column/m-p/204119#M59308</link>
    <description>&lt;P&gt;thank you!&lt;/P&gt;</description>
    <pubDate>Wed, 17 Feb 2016 01:52:59 GMT</pubDate>
    <dc:creator>HattrickNZ</dc:creator>
    <dc:date>2016-02-17T01:52:59Z</dc:date>
    <item>
      <title>How do I use my regular expression to extract values in a column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-my-regular-expression-to-extract-values-in-a-column/m-p/204109#M59298</link>
      <description>&lt;P&gt;I have the following search &lt;CODE&gt;... | stats dc() | transpose |&lt;/CODE&gt; which gives me this: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;column  row 1
dc(ID)  273
dc(SBC) 2
dc(TGID)    273
dc(TGN) 504
dc(beginTime)   2
dc(c1907466966) 54
dc(c1907466967) 59
dc(c1907466968) 55
dc(c1907466969) 31
dc(c1907466970) 50
dc(c1907466971) 55
dc(c1907466972) 7
dc(c1907466973) 47
dc(c1907466974) 57
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I want is to do a regex on this column and extract the values. This is the pattern I am interested in &lt;CODE&gt;dc(c1907466966)&lt;/CODE&gt; and this is what I want to extract &lt;CODE&gt;907466966&lt;/CODE&gt; and store it in a field called &lt;STRONG&gt;name1&lt;/STRONG&gt;. This is the regex I need &lt;CODE&gt;dc\Dc(?P\d+)\D&lt;/CODE&gt;, but I can't apply it to extract that data I want to a field. &lt;/P&gt;

&lt;P&gt;How do I do this?&lt;/P&gt;

&lt;P&gt;This is my regex example&lt;BR /&gt;
&lt;A href="https://regex101.com/r/qO8aS6/1"&gt;https://regex101.com/r/qO8aS6/1&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Feb 2016 21:57:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-my-regular-expression-to-extract-values-in-a-column/m-p/204109#M59298</guid>
      <dc:creator>HattrickNZ</dc:creator>
      <dc:date>2016-02-15T21:57:05Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use my regular expression to extract values in a column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-my-regular-expression-to-extract-values-in-a-column/m-p/204110#M59299</link>
      <description>&lt;P&gt;What do you mean with &lt;CODE&gt;but I can't apply it to extract that data I want to a field&lt;/CODE&gt; ?&lt;/P&gt;

&lt;P&gt;If you run this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count | eval foo="column    row 1
 dc(ID)    273
 dc(SBC)    2
 dc(TGID)    273
 dc(TGN)    504
 dc(beginTime)    2
 dc(c1907466966)    54
 dc(c1907466967)    59
 dc(c1907466968)    55
 dc(c1907466969)    31
 dc(c1907466970)    50
 dc(c1907466971)    55
 dc(c1907466972)    7
 dc(c1907466973)    47
 dc(c1907466974)    57" | rex max_match=0 field=foo "dc\Dc(?&amp;lt;name1&amp;gt;\d+)\D" | table name1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It will create a multi value field called &lt;CODE&gt;name1&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Mon, 15 Feb 2016 22:07:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-my-regular-expression-to-extract-values-in-a-column/m-p/204110#M59299</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2016-02-15T22:07:33Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use my regular expression to extract values in a column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-my-regular-expression-to-extract-values-in-a-column/m-p/204111#M59300</link>
      <description>&lt;P&gt;Try something like this&lt;/P&gt;

&lt;P&gt;To extract 907466968 from dc(c1907466968)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | stats dc(*) | transpose  | rex field=column "dc\(c\d(?P&amp;lt;name1&amp;gt;\d+)\)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;To extract 1907466968 from dc(c1907466968)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | stats dc(*) | transpose  | rex field=column "dc\(c(?P&amp;lt;name1&amp;gt;\d+)\)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 Feb 2016 22:29:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-my-regular-expression-to-extract-values-in-a-column/m-p/204111#M59300</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-02-15T22:29:48Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use my regular expression to extract values in a column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-my-regular-expression-to-extract-values-in-a-column/m-p/204112#M59301</link>
      <description>&lt;P&gt;tks, that something for me to work with.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | stats dc() | transpose | rex field=column "dc\Dc(?P&amp;lt;name1&amp;gt;\d+)\D"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;gives me this(the values I want are in name1 column): &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;column  row 1   name1
dc(ID)  273  
dc(SBC) 2    
dc(TGID)    273  
dc(TGN) 434  
dc(beginTime)   2    
dc(c1907466966) 35  907466966
dc(c1907466967) 39  907466967
dc(c1907466968) 37  907466968
dc(c1907466969) 21  907466969
dc(c1907466970) 34  907466970
dc(c1907466971) 37  907466971
dc(c1907466972) 9   907466972
dc(c1907466973) 32  907466973
dc(c1907466974) 38  907466974
dc(c1907466975) 36  907466975
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But I was hoping there would fe a field value called &lt;CODE&gt;name1&lt;/CODE&gt; viewable in the &lt;CODE&gt;Events&lt;/CODE&gt; tab but I cannot see it there. Can I get it to be there or should it be there? &lt;/P&gt;</description>
      <pubDate>Mon, 15 Feb 2016 23:19:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-my-regular-expression-to-extract-values-in-a-column/m-p/204112#M59301</guid>
      <dc:creator>HattrickNZ</dc:creator>
      <dc:date>2016-02-15T23:19:42Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use my regular expression to extract values in a column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-my-regular-expression-to-extract-values-in-a-column/m-p/204113#M59302</link>
      <description>&lt;P&gt;I want to apply the regex to the values in the column called &lt;CODE&gt;column&lt;/CODE&gt; so I will end up with the values in one field, &lt;CODE&gt;name1&lt;/CODE&gt; like this. &lt;/P&gt;

&lt;P&gt;1 &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;name1
1907466966
1907466967
1907466968
...
1907466969
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;when I say field I mean creating a field where I can do a &lt;CODE&gt;stats values(name1)&lt;/CODE&gt; on  and that will give me something like 1 above&lt;/P&gt;</description>
      <pubDate>Mon, 15 Feb 2016 23:23:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-my-regular-expression-to-extract-values-in-a-column/m-p/204113#M59302</guid>
      <dc:creator>HattrickNZ</dc:creator>
      <dc:date>2016-02-15T23:23:55Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use my regular expression to extract values in a column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-my-regular-expression-to-extract-values-in-a-column/m-p/204114#M59303</link>
      <description>&lt;P&gt;I believe you've field names cXXXXXXXXX in your events. So if you want to extract all the code available in the fields starting with c and available in the events tab itself along with each event, try something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | rex max_match=0 "c\d(?&amp;lt;name1&amp;gt;\d+)" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This should give a field name1, multivalued, containing all the codes. Sample events will help you get better solution.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Feb 2016 23:27:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-my-regular-expression-to-extract-values-in-a-column/m-p/204114#M59303</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-02-15T23:27:06Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use my regular expression to extract values in a column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-my-regular-expression-to-extract-values-in-a-column/m-p/204115#M59304</link>
      <description>&lt;P&gt;that works &lt;BR /&gt;
&lt;CODE&gt;... |  rex max_match=0 "c\d(?\d+)=" | table name1 | dedup name1&lt;/CODE&gt; and this gives me: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;name1
1   
907473350
907473351
907473352
2   
907466983
907466984
907466985
907466986
907466987
907466988
907466989
907466990
907466991
907466992
907466993
907466994
907466995
907466996
3   
907466966
907466967
907466968
907466969
907466970
907466971
907466972
907466973
907466974
907466975
907466976
907466977
907466978
907466979
...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But why is it doing this grouping, do you think? (3 numbers in row1...etc) I would have thought it was 1 number per row.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Feb 2016 00:57:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-my-regular-expression-to-extract-values-in-a-column/m-p/204115#M59304</guid>
      <dc:creator>HattrickNZ</dc:creator>
      <dc:date>2016-02-16T00:57:07Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use my regular expression to extract values in a column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-my-regular-expression-to-extract-values-in-a-column/m-p/204116#M59305</link>
      <description>&lt;P&gt;The field name1 is multivalued field and table and dedup command will not change its format. To get each value in separate events do this after rex.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count by name1 | fields - count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Feb 2016 02:59:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-my-regular-expression-to-extract-values-in-a-column/m-p/204116#M59305</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-02-16T02:59:01Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use my regular expression to extract values in a column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-my-regular-expression-to-extract-values-in-a-column/m-p/204117#M59306</link>
      <description>&lt;P&gt;tks, think thats it. do you just use the count here to get rid of duplicates? &lt;/P&gt;

&lt;P&gt;whil I have you, what I want is &lt;/P&gt;

&lt;P&gt;| rex max_match=0 "c\d(?\d+)" | stats values(name1) by  measInfoId&lt;/P&gt;

&lt;P&gt;and this gives me this: (which is many &lt;CODE&gt;values(name1)&lt;/CODE&gt; per &lt;CODE&gt;measInfoId&lt;/CODE&gt; but all this shows on 1 row.)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    measInfoId  values(name1)
1   1907425280  907465280
907465281
907465282
907465283
907465284
...
2   1907425301  907466042
907466043
907466044
907466045
...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How do I get this to be 1 row per &lt;CODE&gt;values(name1)&lt;/CODE&gt; like &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    measInfoId  values(name1)
1   1907425280  907465280
2                          907465281
3                          907465282
4                          907465283
5                           907465284
...
10  1907425301  907466042
11                                907466043
...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Feb 2016 00:04:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-my-regular-expression-to-extract-values-in-a-column/m-p/204117#M59306</guid>
      <dc:creator>HattrickNZ</dc:creator>
      <dc:date>2016-02-17T00:04:46Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use my regular expression to extract values in a column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-my-regular-expression-to-extract-values-in-a-column/m-p/204118#M59307</link>
      <description>&lt;P&gt;just use this after rex.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...| stats count by measInfoId name1 | fields - count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Feb 2016 01:18:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-my-regular-expression-to-extract-values-in-a-column/m-p/204118#M59307</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-02-17T01:18:31Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use my regular expression to extract values in a column?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-my-regular-expression-to-extract-values-in-a-column/m-p/204119#M59308</link>
      <description>&lt;P&gt;thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 17 Feb 2016 01:52:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-my-regular-expression-to-extract-values-in-a-column/m-p/204119#M59308</guid>
      <dc:creator>HattrickNZ</dc:creator>
      <dc:date>2016-02-17T01:52:59Z</dc:date>
    </item>
  </channel>
</rss>

