<?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: understanding regex better in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/understanding-regex-better/m-p/156418#M44005</link>
    <description>&lt;P&gt;Hi @HattrickNZ&lt;/P&gt;

&lt;P&gt;Just thought you might find this useful, but here's a previous answers post where a handful of users on Answers shared their favorite online (and 1 offline) regex resources. One of them has exercises for practice and better understanding.&lt;BR /&gt;
&lt;A href="http://answers.splunk.com/answers/153171/is-there-any-online-regex-tool-to-create-regular-e.html"&gt;http://answers.splunk.com/answers/153171/is-there-any-online-regex-tool-to-create-regular-e.html&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 27 Apr 2015 20:43:35 GMT</pubDate>
    <dc:creator>ppablo</dc:creator>
    <dc:date>2015-04-27T20:43:35Z</dc:date>
    <item>
      <title>understanding regex better</title>
      <link>https://community.splunk.com/t5/Splunk-Search/understanding-regex-better/m-p/156411#M43998</link>
      <description>&lt;P&gt;I am trying to understand better how splunk regex works.&lt;/P&gt;

&lt;P&gt;I have the below example:&lt;/P&gt;

&lt;P&gt;This is a sample of the data I am trying to extract with &lt;CODE&gt;Slot No.=1&lt;/CODE&gt; being of interest:&lt;BR /&gt;
&lt;CODE&gt;...,measObjLdn="SGSN02KPR/Process:Process No.=5, Process type=GBP, Slot No.=1,...&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Using splunks Interactive field extractor gives me this&lt;BR /&gt;
&lt;CODE&gt;(?i)=.*?, (?P\w+\s+\w+\.=\d+)(?=,)&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;if I want to look at these values in the search I can do this &lt;BR /&gt;
`... |  rex "(?i)=.*?, (?P\w+\s+\w+.=\d+)(?=,)"  | stats values(FIELDNAME)&lt;/P&gt;

&lt;P&gt;Now to understand this better I would like to use an example. What if I just want the values so instead of getting &lt;BR /&gt;
&lt;CODE&gt;Slot No.=1&lt;/CODE&gt; I would get &lt;CODE&gt;1&lt;/CODE&gt; &lt;/P&gt;

&lt;P&gt;So this &lt;CODE&gt;(?i)=.*?, (?P\w+\s+\w+\.=\d+)(?=,)&lt;/CODE&gt; would go to ...?&lt;/P&gt;

&lt;P&gt;Appreciate any help and trying to understand this better, or is there any documentation on this.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;EDIT1&lt;/STRONG&gt;&lt;BR /&gt;
For instance this &lt;CODE&gt;| rex ".*,.*Slot No.=(?P[^,]+)"&lt;/CODE&gt; will give me just the values this is just me playing around, I don't fully understand it.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Apr 2015 01:44:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/understanding-regex-better/m-p/156411#M43998</guid>
      <dc:creator>HattrickNZ</dc:creator>
      <dc:date>2015-04-24T01:44:04Z</dc:date>
    </item>
    <item>
      <title>Re: understanding regex better</title>
      <link>https://community.splunk.com/t5/Splunk-Search/understanding-regex-better/m-p/156412#M43999</link>
      <description>&lt;P&gt;Perhaps for you, its better to do a rex as follows, as you mentioned:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search.. | rex field=_raw "Slot No.\=(?&amp;lt;slot_number&amp;gt;[^,]+),"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This isnt a proper forum to learn regex, but this matches a "Slot No.=" string, and then uses a capture group for any thing that isnt a "," repeated infinite times till it finds a ",".&lt;/P&gt;

&lt;P&gt;Key take away here is regex capture groups, and pattern matching.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Apr 2015 03:27:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/understanding-regex-better/m-p/156412#M43999</guid>
      <dc:creator>esix_splunk</dc:creator>
      <dc:date>2015-04-24T03:27:47Z</dc:date>
    </item>
    <item>
      <title>Re: understanding regex better</title>
      <link>https://community.splunk.com/t5/Splunk-Search/understanding-regex-better/m-p/156413#M44000</link>
      <description>&lt;P&gt;Regex, or regular expressions, are not a idea in only in the world of Splunk. These are used throughout the development world and have been for years. I would recommend you study a bit on PCRE based patterns to get a better understanding of how regular expressions fit into the world of Splunk.&lt;/P&gt;

&lt;P&gt;&lt;A href="http://www.regex101.com"&gt;www.regex101.com&lt;/A&gt; is quite a valuable resource, not to mention others out there..&lt;/P&gt;</description>
      <pubDate>Fri, 24 Apr 2015 03:27:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/understanding-regex-better/m-p/156413#M44000</guid>
      <dc:creator>esix_splunk</dc:creator>
      <dc:date>2015-04-24T03:27:48Z</dc:date>
    </item>
    <item>
      <title>Re: understanding regex better</title>
      <link>https://community.splunk.com/t5/Splunk-Search/understanding-regex-better/m-p/156414#M44001</link>
      <description>&lt;P&gt;tks but would you help me understand and break this down?&lt;/P&gt;

&lt;P&gt;"(?i)=.*?, (?P\w+\s+\w+.=\d+)(?=,)"&lt;/P&gt;

&lt;P&gt;have to rewrite the above as everything between &lt;CODE&gt;&amp;lt;&lt;/CODE&gt; and &lt;CODE&gt;&amp;gt;&lt;/CODE&gt; symbols disappears, but not if i use &lt;CODE&gt;&amp;amp;lt&lt;/CODE&gt; and &lt;CODE&gt;&amp;amp;gt&lt;/CODE&gt; &lt;BR /&gt;
 "(?i)=.*?, (?P&amp;amp;ltFIELDNAME&amp;amp;gt\w+\s+\w+.=\d+)(?=,)"&lt;/P&gt;

&lt;P&gt;&amp;amp;lt = &amp;lt;&lt;BR /&gt;
&amp;amp;gt = &amp;gt;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;&amp;amp;lt&lt;/CODE&gt; = &amp;lt;&lt;BR /&gt;
&lt;CODE&gt;&amp;amp;gt&lt;/CODE&gt; = &amp;gt;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Apr 2015 03:27:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/understanding-regex-better/m-p/156414#M44001</guid>
      <dc:creator>HattrickNZ</dc:creator>
      <dc:date>2015-04-24T03:27:49Z</dc:date>
    </item>
    <item>
      <title>Re: understanding regex better</title>
      <link>https://community.splunk.com/t5/Splunk-Search/understanding-regex-better/m-p/156415#M44002</link>
      <description>&lt;P&gt;tks you have giving me food for thought!! but what is a good forum for regex is it stackoverflow?&lt;/P&gt;</description>
      <pubDate>Fri, 24 Apr 2015 03:52:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/understanding-regex-better/m-p/156415#M44002</guid>
      <dc:creator>HattrickNZ</dc:creator>
      <dc:date>2015-04-24T03:52:30Z</dc:date>
    </item>
    <item>
      <title>Re: understanding regex better</title>
      <link>https://community.splunk.com/t5/Splunk-Search/understanding-regex-better/m-p/156416#M44003</link>
      <description>&lt;P&gt;You can learn regex as you go I believe, you only really need help in truly complicated cases. What helps a lot is a tool like &lt;A href="https://regex101.com/"&gt;regex101&lt;/A&gt; where you can try your expression on your sample data and which highlights your syntax graphically, explains your regex step for step and also has a quick reference of frequently used commands at hand - it's really great!&lt;/P&gt;

&lt;P&gt;If you DO post regex code here, please keep in mind to post it as code - not with grave accents, but with an empty row before it and indented by four spaces. That will preserve any special characters such as angular brackets, which, as you can see, are lost in the question you posted.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Apr 2015 05:25:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/understanding-regex-better/m-p/156416#M44003</guid>
      <dc:creator>jeffland</dc:creator>
      <dc:date>2015-04-24T05:25:20Z</dc:date>
    </item>
    <item>
      <title>Re: understanding regex better</title>
      <link>https://community.splunk.com/t5/Splunk-Search/understanding-regex-better/m-p/156417#M44004</link>
      <description>&lt;P&gt;tks Jeff &lt;/P&gt;

&lt;P&gt;Below posted using the code button above (&lt;PRE&gt; &lt;CODE&gt;)&lt;/CODE&gt;&lt;/PRE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"(?i)=.*?, (?P&amp;lt;FIELDNAME&amp;gt;w+s+w+.=d+)(?=,)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Below posted using grave accents - Note the difference&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;"(?i)=.*?, (?Pw+s+w+.=d+)(?=,)"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Apr 2015 19:57:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/understanding-regex-better/m-p/156417#M44004</guid>
      <dc:creator>HattrickNZ</dc:creator>
      <dc:date>2015-04-27T19:57:54Z</dc:date>
    </item>
    <item>
      <title>Re: understanding regex better</title>
      <link>https://community.splunk.com/t5/Splunk-Search/understanding-regex-better/m-p/156418#M44005</link>
      <description>&lt;P&gt;Hi @HattrickNZ&lt;/P&gt;

&lt;P&gt;Just thought you might find this useful, but here's a previous answers post where a handful of users on Answers shared their favorite online (and 1 offline) regex resources. One of them has exercises for practice and better understanding.&lt;BR /&gt;
&lt;A href="http://answers.splunk.com/answers/153171/is-there-any-online-regex-tool-to-create-regular-e.html"&gt;http://answers.splunk.com/answers/153171/is-there-any-online-regex-tool-to-create-regular-e.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Apr 2015 20:43:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/understanding-regex-better/m-p/156418#M44005</guid>
      <dc:creator>ppablo</dc:creator>
      <dc:date>2015-04-27T20:43:35Z</dc:date>
    </item>
  </channel>
</rss>

