<?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 use wildcard inside string regex? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-wildcard-inside-string-regex/m-p/345018#M102209</link>
    <description>&lt;P&gt;Give this a try (single rex to extract both)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex "name[^\:]+\:(?&amp;lt;name&amp;gt;\w+)_(device\:)*(?&amp;lt;device&amp;gt;\w+)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 06 Nov 2017 21:57:01 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2017-11-06T21:57:01Z</dc:date>
    <item>
      <title>How to use wildcard inside string regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-wildcard-inside-string-regex/m-p/345015#M102206</link>
      <description>&lt;P&gt;The log contains string in this format below.&lt;/P&gt;

&lt;P&gt;name:X_device:Y_&lt;BR /&gt;
name-U:X1_Y2_&lt;/P&gt;

&lt;P&gt;It has a mixed pattern, and I'm wondering how to use wildcard if I do the regex for name and device in a string (inside double quotations) like below?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex "name *wildcard* (?&amp;lt;name&amp;gt;\w*)_"
rex "device *wildcard* (?&amp;lt;device&amp;gt;\w*)_"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:34:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-wildcard-inside-string-regex/m-p/345015#M102206</guid>
      <dc:creator>limalbert</dc:creator>
      <dc:date>2020-09-29T16:34:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to use wildcard inside string regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-wildcard-inside-string-regex/m-p/345016#M102207</link>
      <description>&lt;P&gt;Hey @limalbert, Please format any search/code/data sample that you post using code button (button with '101010' above the editor) or by pressing Ctrl+K.&lt;/P&gt;

&lt;P&gt;In the 2nd example, there is no keyword for device, is that correct or typo? Are you looking for wildcarding the one which I highlighed  here: &lt;CODE&gt;name**:**X&lt;/CODE&gt; and &lt;CODE&gt;name**-U:**X1&lt;/CODE&gt; ??&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2017 21:40:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-wildcard-inside-string-regex/m-p/345016#M102207</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-11-06T21:40:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to use wildcard inside string regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-wildcard-inside-string-regex/m-p/345017#M102208</link>
      <description>&lt;P&gt;Hi @somesoni,&lt;/P&gt;

&lt;P&gt;I edited the question.&lt;/P&gt;

&lt;P&gt;For the second example for device, there is no keyword, and that's why it's a little bit difficult. I found another alternate to wildcard by using this &lt;STRONG&gt;(?:[^/]+)?&lt;/STRONG&gt;. I successfully use this to get name field, but I'm still working on the device since it doesn't have keyword.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex "name(?:[^/]+)?:(?&amp;lt;name&amp;gt;\w*)_"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Nov 2017 21:53:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-wildcard-inside-string-regex/m-p/345017#M102208</guid>
      <dc:creator>limalbert</dc:creator>
      <dc:date>2017-11-06T21:53:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to use wildcard inside string regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-wildcard-inside-string-regex/m-p/345018#M102209</link>
      <description>&lt;P&gt;Give this a try (single rex to extract both)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex "name[^\:]+\:(?&amp;lt;name&amp;gt;\w+)_(device\:)*(?&amp;lt;device&amp;gt;\w+)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Nov 2017 21:57:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-wildcard-inside-string-regex/m-p/345018#M102209</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-11-06T21:57:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to use wildcard inside string regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-wildcard-inside-string-regex/m-p/345019#M102210</link>
      <description>&lt;P&gt;The concept of "wildcard" is more refined in regex so you just have to use the regex format.  If you expect 0 or more repetitions of any character, for example, you would use &lt;CODE&gt;.*&lt;/CODE&gt; instead if just &lt;CODE&gt;*&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;In regex, &lt;CODE&gt;*&lt;/CODE&gt; means 0 or more repetition of any character preceding it; in one of your examples, &lt;CODE&gt;name *wildcard*&lt;/CODE&gt;, the first "*" represents 0 or more white spaces, whereas the second "*" represents 0 or more letter "d".  If you want your "wildcard" to represent any character in any repetition, you precede "*" with special character ".", which in regex can represent any singe character.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2017 22:07:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-wildcard-inside-string-regex/m-p/345019#M102210</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2017-11-06T22:07:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to use wildcard inside string regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-wildcard-inside-string-regex/m-p/345020#M102211</link>
      <description>&lt;P&gt;Can you help me understand what you did after name? Specifically this one, &lt;STRONG&gt;[^:]+&lt;/STRONG&gt;.&lt;BR /&gt;
Also, it works to get only the first device, so the only output is &lt;STRONG&gt;device:Y&lt;/STRONG&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2017 22:17:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-wildcard-inside-string-regex/m-p/345020#M102211</guid>
      <dc:creator>limalbert</dc:creator>
      <dc:date>2017-11-06T22:17:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to use wildcard inside string regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-wildcard-inside-string-regex/m-p/345021#M102212</link>
      <description>&lt;P&gt;Sorry, the output for device is actually only "Y". It only give the one with keyword, but it doesn't give the one without keyword.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2017 22:22:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-wildcard-inside-string-regex/m-p/345021#M102212</guid>
      <dc:creator>limalbert</dc:creator>
      <dc:date>2017-11-06T22:22:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to use wildcard inside string regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-wildcard-inside-string-regex/m-p/345022#M102213</link>
      <description>&lt;P&gt;This should do it. (runanywhere sample search. Replace everything before rex with your search)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-1 | eval raw="name:X_device:Y_#name-U:X1_Y2_" | table raw | makemv raw delim="#" | mvexpand raw | rename raw as _raw 
|rex "name[^:]*:(?&amp;lt;name&amp;gt;[^_]+)_(device:)*(?&amp;lt;device&amp;gt;[^_]+)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Nov 2017 23:28:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-wildcard-inside-string-regex/m-p/345022#M102213</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-11-06T23:28:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to use wildcard inside string regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-wildcard-inside-string-regex/m-p/345023#M102214</link>
      <description>&lt;P&gt;Thank you! This works!&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2017 02:15:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-wildcard-inside-string-regex/m-p/345023#M102214</guid>
      <dc:creator>limalbert</dc:creator>
      <dc:date>2017-11-07T02:15:34Z</dc:date>
    </item>
  </channel>
</rss>

