<?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: Is there a way to use wildcards or regex in lookup csv file? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-wildcards-or-regex-in-lookup-csv-file/m-p/198820#M57541</link>
    <description>&lt;P&gt;You might be able to adapt something like the following:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;search-goes-here | eval OSGroup=case(match(OSName,"Microsoft Windows 7(.*)"),"Windows Client", match(OSName,"Microsoft Windows 8(.*)"),"Windows Client",match(OSName,"Microsoft Windows Server(.*)"),"Windows Server")&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;The second argument to each &lt;CODE&gt;match&lt;/CODE&gt; function is a regex, and the &lt;CODE&gt;case&lt;/CODE&gt; statement lets you line up your matches with your output values.&lt;/P&gt;

&lt;P&gt;While you can't put these in CSV files, you can turn the &lt;CODE&gt;eval&lt;/CODE&gt; clause into a macro (add it to &lt;CODE&gt;macros.conf&lt;/CODE&gt;) and refer to it wherever you need it.&lt;/P&gt;</description>
    <pubDate>Mon, 16 Jun 2014 16:23:59 GMT</pubDate>
    <dc:creator>aweitzman</dc:creator>
    <dc:date>2014-06-16T16:23:59Z</dc:date>
    <item>
      <title>Is there a way to use wildcards or regex in lookup csv file?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-wildcards-or-regex-in-lookup-csv-file/m-p/198819#M57540</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;

&lt;P&gt;Following up on a previous question about lookups I am looking for a way to either use or simulate wildcards in a .csv lookup file.&lt;/P&gt;

&lt;P&gt;I have fields like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Microsoft Windows 8.1 Pro
Microsoft Windows 8 Pro
Microsoft Windows 7 Ultimate
Microsoft Windows 7 Professional
Microsoft Windows 7 Enterprise
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;which I would like to group under, say, &lt;CODE&gt;Windows Clients&lt;/CODE&gt; via a lookup. I do not know in advance what the values will be, so ideally I would like to be able to say&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Microsoft Windows 7*,Windows Client
Microsoft Windows 8*,Windows Client
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;which does not work as is (and was hinted so by &lt;A href="http://answers.splunk.com/users/171373/aweitzman"&gt;aweitzman&lt;/A&gt; in his answer.&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;is there a direct way to use regexp (or wildcards) in the lookup .csv file?&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;The alternate solution I can think about would be to use an external script for the lookup which would get the field value and output something, based on a logic/algorithm within the script (as opposed to a csv)&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jun 2014 15:25:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-wildcards-or-regex-in-lookup-csv-file/m-p/198819#M57540</guid>
      <dc:creator>wsw70</dc:creator>
      <dc:date>2014-06-16T15:25:51Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to use wildcards or regex in lookup csv file?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-wildcards-or-regex-in-lookup-csv-file/m-p/198820#M57541</link>
      <description>&lt;P&gt;You might be able to adapt something like the following:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;search-goes-here | eval OSGroup=case(match(OSName,"Microsoft Windows 7(.*)"),"Windows Client", match(OSName,"Microsoft Windows 8(.*)"),"Windows Client",match(OSName,"Microsoft Windows Server(.*)"),"Windows Server")&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;The second argument to each &lt;CODE&gt;match&lt;/CODE&gt; function is a regex, and the &lt;CODE&gt;case&lt;/CODE&gt; statement lets you line up your matches with your output values.&lt;/P&gt;

&lt;P&gt;While you can't put these in CSV files, you can turn the &lt;CODE&gt;eval&lt;/CODE&gt; clause into a macro (add it to &lt;CODE&gt;macros.conf&lt;/CODE&gt;) and refer to it wherever you need it.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jun 2014 16:23:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-wildcards-or-regex-in-lookup-csv-file/m-p/198820#M57541</guid>
      <dc:creator>aweitzman</dc:creator>
      <dc:date>2014-06-16T16:23:59Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to use wildcards or regex in lookup csv file?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-wildcards-or-regex-in-lookup-csv-file/m-p/198821#M57542</link>
      <description>&lt;P&gt;Hmmm... it looks like there's more to transforms.conf than I realized.&lt;/P&gt;

&lt;P&gt;You can put wildcards in the CSV file, and then add the following term to the appropriate stanza in transforms.conf and it will work:&lt;/P&gt;

&lt;P&gt;match_type = WILDCARD(OSName)&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jun 2014 16:40:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-use-wildcards-or-regex-in-lookup-csv-file/m-p/198821#M57542</guid>
      <dc:creator>aweitzman</dc:creator>
      <dc:date>2014-06-16T16:40:44Z</dc:date>
    </item>
  </channel>
</rss>

