<?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 Regular expressions to match a specific string for field exctraction in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Regular-expressions-to-match-a-specific-string-for-field/m-p/454743#M128649</link>
    <description>&lt;P&gt;I have this type of log file:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;182.236.164.11 - - [04/Mar/2019:18:20:56] "GET /cart.do?action=addtocart&amp;amp;itemId=EST-15&amp;amp;productId=BS-AG-G09&amp;amp;JSESSIONID=SD6SL8FF10ADFF53101 HTTP 1.1" 200 2252 "http://www.buttercupgames.com/oldlink?itemId=EST-15" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.46 Safari/536.5" 506
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I am trying to create a regular expression to only match the word Intel, regardless of the relative position of the string in order to create a field.&lt;/P&gt;

&lt;P&gt;I have come up with this regular expression from the automated regex generator in splunk: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;^[^;\n]*;\s+
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But it doesn't always work as it will match other strings as well.&lt;/P&gt;

&lt;P&gt;I want to match the string Intel only so as to create a field in Splunk.&lt;/P&gt;

&lt;P&gt;I have also tried the following code as to only match the word but still to no avail:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;\bIntel\(?P&amp;lt;CPU&amp;gt;\w+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any inputs are welcome.&lt;/P&gt;</description>
    <pubDate>Fri, 22 Mar 2019 11:22:43 GMT</pubDate>
    <dc:creator>kstam2</dc:creator>
    <dc:date>2019-03-22T11:22:43Z</dc:date>
    <item>
      <title>Regular expressions to match a specific string for field exctraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regular-expressions-to-match-a-specific-string-for-field/m-p/454743#M128649</link>
      <description>&lt;P&gt;I have this type of log file:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;182.236.164.11 - - [04/Mar/2019:18:20:56] "GET /cart.do?action=addtocart&amp;amp;itemId=EST-15&amp;amp;productId=BS-AG-G09&amp;amp;JSESSIONID=SD6SL8FF10ADFF53101 HTTP 1.1" 200 2252 "http://www.buttercupgames.com/oldlink?itemId=EST-15" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.46 Safari/536.5" 506
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I am trying to create a regular expression to only match the word Intel, regardless of the relative position of the string in order to create a field.&lt;/P&gt;

&lt;P&gt;I have come up with this regular expression from the automated regex generator in splunk: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;^[^;\n]*;\s+
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But it doesn't always work as it will match other strings as well.&lt;/P&gt;

&lt;P&gt;I want to match the string Intel only so as to create a field in Splunk.&lt;/P&gt;

&lt;P&gt;I have also tried the following code as to only match the word but still to no avail:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;\bIntel\(?P&amp;lt;CPU&amp;gt;\w+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any inputs are welcome.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2019 11:22:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regular-expressions-to-match-a-specific-string-for-field/m-p/454743#M128649</guid>
      <dc:creator>kstam2</dc:creator>
      <dc:date>2019-03-22T11:22:43Z</dc:date>
    </item>
    <item>
      <title>Re: Regular expressions to match a specific string for field exctraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regular-expressions-to-match-a-specific-string-for-field/m-p/454744#M128650</link>
      <description>&lt;P&gt;Why do you need regex ? If you want to search only &lt;CODE&gt;Intel&lt;/CODE&gt; word in raw data then you can use below query&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=blabla sourcetype=abcxyz "Intel"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Mar 2019 12:45:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regular-expressions-to-match-a-specific-string-for-field/m-p/454744#M128650</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2019-03-22T12:45:08Z</dc:date>
    </item>
    <item>
      <title>Re: Regular expressions to match a specific string for field exctraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regular-expressions-to-match-a-specific-string-for-field/m-p/454745#M128651</link>
      <description>&lt;P&gt;If you just want to match the word 'intel' this will do it:&lt;BR /&gt;
&lt;CODE&gt;(?P&amp;lt;cpu&amp;gt;[iI][nN][tT][eE][lL])&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;If you want to pull more out of the user agent you could also use something like:&lt;BR /&gt;
&lt;CODE&gt;\s\((?P&amp;lt;platorm&amp;gt;\w+)\;\s(?P&amp;lt;arch&amp;gt;\w+)\s(?P&amp;lt;os&amp;gt;[^\)]+)\)&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2019 12:48:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regular-expressions-to-match-a-specific-string-for-field/m-p/454745#M128651</guid>
      <dc:creator>nickhills</dc:creator>
      <dc:date>2019-03-22T12:48:38Z</dc:date>
    </item>
    <item>
      <title>Re: Regular expressions to match a specific string for field exctraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regular-expressions-to-match-a-specific-string-for-field/m-p/454746#M128652</link>
      <description>&lt;P&gt;@kstam2&lt;/P&gt;

&lt;P&gt;If you want to literallly search for the string intel , &lt;CODE&gt;|rex field=_raw "(?&amp;lt;CPU&amp;gt;Intel)"&lt;/CODE&gt; should work. However, that does not make much since you can just do it with eval CPU="Intel"  as well if the value is always "Intel". If you are looking for finding the CPU types, then probably you should try &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;\(\w+;(?&amp;lt;CPU&amp;gt;\s+\w+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you have other OS types and different event formats, please share more samples so that the regex can be adjusted to your needs.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2019 12:49:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regular-expressions-to-match-a-specific-string-for-field/m-p/454746#M128652</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2019-03-22T12:49:01Z</dc:date>
    </item>
    <item>
      <title>Re: Regular expressions to match a specific string for field exctraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regular-expressions-to-match-a-specific-string-for-field/m-p/454747#M128653</link>
      <description>&lt;P&gt;If you want to make it shorter you could also use &lt;STRONG&gt;(?i)&lt;/STRONG&gt; (where i means: insensitive. Case insensitive match (ignores case of [a-zA-Z])&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?i)(?&amp;lt;cpu&amp;gt;intel)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here you could test it:&lt;BR /&gt;
&lt;A href="https://regex101.com/r/3pCOHf/1"&gt;https://regex101.com/r/3pCOHf/1&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Dec 2019 16:42:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regular-expressions-to-match-a-specific-string-for-field/m-p/454747#M128653</guid>
      <dc:creator>manuelostertag</dc:creator>
      <dc:date>2019-12-11T16:42:25Z</dc:date>
    </item>
    <item>
      <title>Re: Regular expressions to match a specific string for field exctraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regular-expressions-to-match-a-specific-string-for-field/m-p/454748#M128654</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|  makeresults
| eval _raw="182.236.164.11 - - [04/Mar/2019:18:20:56] \"GET /cart.do?action=addtocart&amp;amp;itemId=EST-15&amp;amp;productId=BS-AG-G09&amp;amp;JSESSIONID=SD6SL8FF10ADFF53101 HTTP 1.1\" 200 2252 \"http://www.buttercupgames.com/oldlink?itemId=EST-15\" \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.46 Safari/536.5\" 506"
| rex "^(?:\S+\s+){4}\"[^\"]+\"\s*(?:\S+\s+){2}(?:\"[^\"]+\"\s*)\"(?&amp;lt;useragent&amp;gt;[^\"]+)"
| rename COMMENT AS "You should already have a 'useragent' field"
| rex field=useragent ";\s+(?&amp;lt;CPU&amp;gt;\S+)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Dec 2019 12:02:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regular-expressions-to-match-a-specific-string-for-field/m-p/454748#M128654</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-12-13T12:02:47Z</dc:date>
    </item>
  </channel>
</rss>

