<?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 write regex to extract all the numbers in a string in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-i-write-regex-to-extract-all-the-numbers-in-a-string/m-p/321642#M96077</link>
    <description>&lt;P&gt;If you want only the digits in the raw event remove everything else, then instead of extracting simply use replace -&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;base search&amp;gt; |  eval digits=replace(_raw,"\D","") | table digits
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 30 May 2017 07:08:32 GMT</pubDate>
    <dc:creator>dineshraj9</dc:creator>
    <dc:date>2017-05-30T07:08:32Z</dc:date>
    <item>
      <title>How do i write regex to extract all the numbers in a string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-i-write-regex-to-extract-all-the-numbers-in-a-string/m-p/321640#M96075</link>
      <description>&lt;P&gt;i need to extract all the numbers in the below string. I am using "(?\d+[0-9])"  but its not extracting zeros and i am getting only 53  as the answer&lt;/P&gt;

&lt;P&gt;0.0.0.53.IN-BRR.CRPD 1.0.0.127.icmpbugtest.157.kn-ddr.prpd&lt;/P&gt;

&lt;P&gt;I have to get an answer : 00053100127157&lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2017 01:56:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-i-write-regex-to-extract-all-the-numbers-in-a-string/m-p/321640#M96075</guid>
      <dc:creator>sameeripro</dc:creator>
      <dc:date>2017-05-30T01:56:15Z</dc:date>
    </item>
    <item>
      <title>Re: How do i write regex to extract all the numbers in a string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-i-write-regex-to-extract-all-the-numbers-in-a-string/m-p/321641#M96076</link>
      <description>&lt;P&gt;well, check this one - &lt;BR /&gt;
&lt;CODE&gt;your base search | rex field=_raw "(?&amp;lt;YourNumber&amp;gt;\d+)$"  | table YourNumber&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2017 07:01:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-i-write-regex-to-extract-all-the-numbers-in-a-string/m-p/321641#M96076</guid>
      <dc:creator>inventsekar</dc:creator>
      <dc:date>2017-05-30T07:01:14Z</dc:date>
    </item>
    <item>
      <title>Re: How do i write regex to extract all the numbers in a string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-i-write-regex-to-extract-all-the-numbers-in-a-string/m-p/321642#M96077</link>
      <description>&lt;P&gt;If you want only the digits in the raw event remove everything else, then instead of extracting simply use replace -&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;base search&amp;gt; |  eval digits=replace(_raw,"\D","") | table digits
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 May 2017 07:08:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-i-write-regex-to-extract-all-the-numbers-in-a-string/m-p/321642#M96077</guid>
      <dc:creator>dineshraj9</dc:creator>
      <dc:date>2017-05-30T07:08:32Z</dc:date>
    </item>
    <item>
      <title>Re: How do i write regex to extract all the numbers in a string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-i-write-regex-to-extract-all-the-numbers-in-a-string/m-p/321643#M96078</link>
      <description>&lt;P&gt;Just like this but you might prefer to replace _raw with fieldName that contains the string.&lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2017 13:05:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-i-write-regex-to-extract-all-the-numbers-in-a-string/m-p/321643#M96078</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2017-05-30T13:05:10Z</dc:date>
    </item>
    <item>
      <title>Re: How do i write regex to extract all the numbers in a string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-i-write-regex-to-extract-all-the-numbers-in-a-string/m-p/321644#M96079</link>
      <description>&lt;P&gt;That will extract the first set of consecutive digits in _raw, which in this example would be a single 0 character.&lt;/P&gt;

&lt;P&gt;To make a correct extraction, add &lt;CODE&gt;max_match=0&lt;/CODE&gt;,  then use &lt;CODE&gt;mvjoin&lt;/CODE&gt; with an empty string as the separator value to concatenate the multivalue fields together into a single string.  dineshraj9's method is more elegant.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | rex field=_raw "(?&amp;lt;YourNumber&amp;gt;\d+)$"  max_match=0  | eval YourNumber=mvjoin(YourNumber,"") | table YourNumber
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 May 2017 13:35:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-i-write-regex-to-extract-all-the-numbers-in-a-string/m-p/321644#M96079</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-05-30T13:35:43Z</dc:date>
    </item>
    <item>
      <title>Re: How do i write regex to extract all the numbers in a string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-i-write-regex-to-extract-all-the-numbers-in-a-string/m-p/321645#M96080</link>
      <description>&lt;P&gt;@dineshraj9 - great answer! &lt;/P&gt;

&lt;P&gt;@jkat54 - It's a kind of weird string, so I'd expect that it probably is the entire _raw, but you were right that optionally changing the source field was worth mentioning. &lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2017 13:39:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-i-write-regex-to-extract-all-the-numbers-in-a-string/m-p/321645#M96080</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-05-30T13:39:44Z</dc:date>
    </item>
    <item>
      <title>Re: How do i write regex to extract all the numbers in a string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-i-write-regex-to-extract-all-the-numbers-in-a-string/m-p/321646#M96081</link>
      <description>&lt;P&gt;I downvoted this post because removing my accidental upvote&lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2017 13:40:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-i-write-regex-to-extract-all-the-numbers-in-a-string/m-p/321646#M96081</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-05-30T13:40:18Z</dc:date>
    </item>
    <item>
      <title>Re: How do i write regex to extract all the numbers in a string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-i-write-regex-to-extract-all-the-numbers-in-a-string/m-p/321647#M96082</link>
      <description>&lt;P&gt;Yeah i didnt see that space in the string... its possible this is two fields, etc.  So the _raw approach is probably the best.&lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2017 14:05:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-i-write-regex-to-extract-all-the-numbers-in-a-string/m-p/321647#M96082</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2017-05-30T14:05:09Z</dc:date>
    </item>
    <item>
      <title>Re: How do i write regex to extract all the numbers in a string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-i-write-regex-to-extract-all-the-numbers-in-a-string/m-p/321648#M96083</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval digits=_raw | rex field=digits mode=sed "s/\D//g"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 May 2017 14:38:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-i-write-regex-to-extract-all-the-numbers-in-a-string/m-p/321648#M96083</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-05-30T14:38:22Z</dc:date>
    </item>
    <item>
      <title>Re: How do i write regex to extract all the numbers in a string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-i-write-regex-to-extract-all-the-numbers-in-a-string/m-p/321649#M96084</link>
      <description>&lt;P&gt;To un-upvote just click on the up arrow again.  It should turn grey.&lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2017 15:35:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-i-write-regex-to-extract-all-the-numbers-in-a-string/m-p/321649#M96084</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2017-05-30T15:35:23Z</dc:date>
    </item>
    <item>
      <title>Re: How do i write regex to extract all the numbers in a string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-i-write-regex-to-extract-all-the-numbers-in-a-string/m-p/321650#M96085</link>
      <description>&lt;P&gt;this worked as i wanted to extract numbers only from a single field that is "query" i used  |  eval digits=replace(query,"\D","") | table digits&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 02:37:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-i-write-regex-to-extract-all-the-numbers-in-a-string/m-p/321650#M96085</guid>
      <dc:creator>sameeripro</dc:creator>
      <dc:date>2017-05-31T02:37:10Z</dc:date>
    </item>
    <item>
      <title>Re: How do i write regex to extract all the numbers in a string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-i-write-regex-to-extract-all-the-numbers-in-a-string/m-p/321651#M96086</link>
      <description>&lt;P&gt;in rex field=_raw "(?\d+)$" iam getting only the last part &lt;/P&gt;

&lt;P&gt;Example&lt;/P&gt;

&lt;P&gt;10.0.0.1  i am getting 1&lt;BR /&gt;
123example567.com  i am getting 567&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 02:38:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-i-write-regex-to-extract-all-the-numbers-in-a-string/m-p/321651#M96086</guid>
      <dc:creator>sameeripro</dc:creator>
      <dc:date>2017-05-31T02:38:44Z</dc:date>
    </item>
    <item>
      <title>Re: How do i write regex to extract all the numbers in a string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-i-write-regex-to-extract-all-the-numbers-in-a-string/m-p/321652#M96087</link>
      <description>&lt;P&gt;In this query i am getting results  only if the string ends with a number.&lt;/P&gt;

&lt;P&gt;Example&lt;BR /&gt;
 for 10.0.0.1 i am getting 1&lt;BR /&gt;
for 123example567.com i am getting zero results&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 02:43:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-i-write-regex-to-extract-all-the-numbers-in-a-string/m-p/321652#M96087</guid>
      <dc:creator>sameeripro</dc:creator>
      <dc:date>2017-05-31T02:43:28Z</dc:date>
    </item>
    <item>
      <title>Re: How do i write regex to extract all the numbers in a string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-i-write-regex-to-extract-all-the-numbers-in-a-string/m-p/321653#M96088</link>
      <description>&lt;P&gt;@woodcock Even this query worked thank you very much  @woodcock&lt;BR /&gt;
| eval digits=_raw | rex field=digits mode=sed "s/\D//g"&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 02:46:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-i-write-regex-to-extract-all-the-numbers-in-a-string/m-p/321653#M96088</guid>
      <dc:creator>sameeripro</dc:creator>
      <dc:date>2017-05-31T02:46:39Z</dc:date>
    </item>
    <item>
      <title>Re: How do i write regex to extract all the numbers in a string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-i-write-regex-to-extract-all-the-numbers-in-a-string/m-p/321654#M96089</link>
      <description>&lt;P&gt;@jkat54 Thank you very much&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 02:47:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-i-write-regex-to-extract-all-the-numbers-in-a-string/m-p/321654#M96089</guid>
      <dc:creator>sameeripro</dc:creator>
      <dc:date>2017-05-31T02:47:24Z</dc:date>
    </item>
    <item>
      <title>Re: How do i write regex to extract all the numbers in a string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-i-write-regex-to-extract-all-the-numbers-in-a-string/m-p/321655#M96090</link>
      <description>&lt;P&gt;@woodcock  i am seeing mode=sed "s/\D//g" type of regex for first time can you throw some light on this as i want to learn.&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 02:49:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-i-write-regex-to-extract-all-the-numbers-in-a-string/m-p/321655#M96090</guid>
      <dc:creator>sameeripro</dc:creator>
      <dc:date>2017-05-31T02:49:05Z</dc:date>
    </item>
    <item>
      <title>Re: How do i write regex to extract all the numbers in a string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-i-write-regex-to-extract-all-the-numbers-in-a-string/m-p/321656#M96091</link>
      <description>&lt;P&gt;You can go to this site- &lt;A href="http://regex101.com/"&gt;http://regex101.com/&lt;/A&gt; to learn more about regular expressions and test them.&lt;/P&gt;

&lt;P&gt;\d token stands for any digit&lt;BR /&gt;
\D stands for any non digit&lt;/P&gt;

&lt;P&gt;More on sed expression here - &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.6.1/SearchReference/Rex#Sed_expression"&gt;http://docs.splunk.com/Documentation/Splunk/6.6.1/SearchReference/Rex#Sed_expression&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 03:55:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-i-write-regex-to-extract-all-the-numbers-in-a-string/m-p/321656#M96091</guid>
      <dc:creator>dineshraj9</dc:creator>
      <dc:date>2017-05-31T03:55:12Z</dc:date>
    </item>
    <item>
      <title>Re: How do i write regex to extract all the numbers in a string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-i-write-regex-to-extract-all-the-numbers-in-a-string/m-p/321657#M96092</link>
      <description>&lt;P&gt;This is in the search manual, under search command &lt;CODE&gt;rex&lt;/CODE&gt;, look for &lt;CODE&gt;mode=sed&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;Go to regex101.com for testing any particular regular expression, or go to these sites to learn about them. I would suggest the first one first, although it has a number of places where it will tell you about multiple different "flavors" or "dialects", as opposed to being splunk-specific.&lt;/P&gt;

&lt;P&gt;&lt;A href="http://www.regular-expressions.info/reference.html"&gt;http://www.regular-expressions.info/reference.html&lt;/A&gt;&lt;BR /&gt;
&lt;A href="https://regexone.com/"&gt;https://regexone.com/&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;The other thing to be aware of is that sometimes you will have to escape (put a slash in front of) a character in splunk in order that the splunk processor will correctly interpret the regular expression, and it takes a little bit of familiarity to know when to add extra slashes because splunk is going to do multiple passes on the regex string.  Don't worry about that too much, just get your feet wet and ask for help when you have a specific question.&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 04:24:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-i-write-regex-to-extract-all-the-numbers-in-a-string/m-p/321657#M96092</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-05-31T04:24:59Z</dc:date>
    </item>
    <item>
      <title>Re: How do i write regex to extract all the numbers in a string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-i-write-regex-to-extract-all-the-numbers-in-a-string/m-p/321658#M96093</link>
      <description>&lt;P&gt;There is a unix tool called &lt;CODE&gt;sed&lt;/CODE&gt; which uses some RegEx-based syntax but has other peculiarities special to it.  It is particularly useful when it is necessary to strip characters or re-arrange susbstrings.   This says to use &lt;CODE&gt;sed&lt;/CODE&gt; instead of normal &lt;CODE&gt;RegEx&lt;/CODE&gt; when applying the command string to the field to modify.&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 18:51:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-i-write-regex-to-extract-all-the-numbers-in-a-string/m-p/321658#M96093</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-05-31T18:51:16Z</dc:date>
    </item>
  </channel>
</rss>

