<?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 match a regex query in a CSV? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-match-a-regex-query-in-a-CSV/m-p/429645#M122892</link>
    <description>&lt;P&gt;@JohnGilmour if this answer or the other one assisted you, please make sure to accept either of them as the accepted answer.  Thank you!&lt;/P&gt;</description>
    <pubDate>Fri, 05 Apr 2019 20:24:20 GMT</pubDate>
    <dc:creator>dmarling</dc:creator>
    <dc:date>2019-04-05T20:24:20Z</dc:date>
    <item>
      <title>How do I match a regex query in a CSV?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-match-a-regex-query-in-a-CSV/m-p/429640#M122887</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I have a CSV file full of regex queries. What I am looking at doing is matching those with a regex in the CSV.  &lt;/P&gt;

&lt;P&gt;Ideas?&lt;/P&gt;</description>
      <pubDate>Wed, 12 Dec 2018 14:36:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-match-a-regex-query-in-a-CSV/m-p/429640#M122887</guid>
      <dc:creator>JohnGilmour</dc:creator>
      <dc:date>2018-12-12T14:36:32Z</dc:date>
    </item>
    <item>
      <title>Re: How do I match a regex query in a CSV?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-match-a-regex-query-in-a-CSV/m-p/429641#M122888</link>
      <description>&lt;P&gt;Can you provide a bit more information such as an example of the data in the csv and how you are attempting to use it in a dashboard/query?&lt;/P&gt;</description>
      <pubDate>Wed, 12 Dec 2018 15:03:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-match-a-regex-query-in-a-CSV/m-p/429641#M122888</guid>
      <dc:creator>dmarling</dc:creator>
      <dc:date>2018-12-12T15:03:13Z</dc:date>
    </item>
    <item>
      <title>Re: How do I match a regex query in a CSV?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-match-a-regex-query-in-a-CSV/m-p/429642#M122889</link>
      <description>&lt;P&gt;Hello - I'm looking at a dashboard for Spam, with the email SUBJECT (Field) matching a regex in a file. &lt;/P&gt;

&lt;P&gt;AKA if the subject matches one of the regex rules in the file.  &lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;E.G&lt;/STRONG&gt;&lt;BR /&gt;
e-?ma[il1]+ .{0,10}suspen&lt;BR /&gt;
e-?ma[il1]{1,} user&lt;BR /&gt;
from.helpdesk&lt;BR /&gt;
fu[il1]{2,}.*ma[il1]+[ -]?box&lt;/P&gt;

&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Wed, 12 Dec 2018 15:15:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-match-a-regex-query-in-a-CSV/m-p/429642#M122889</guid>
      <dc:creator>JohnGilmour</dc:creator>
      <dc:date>2018-12-12T15:15:13Z</dc:date>
    </item>
    <item>
      <title>Re: How do I match a regex query in a CSV?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-match-a-regex-query-in-a-CSV/m-p/429643#M122890</link>
      <description>&lt;P&gt;The performance will be awful, but you could probably do it with &lt;CODE&gt;map&lt;/CODE&gt;.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup regex.csv | map search="index=foo SUBJECT=* | where match(SUBJECT, "$regex$")"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Dec 2018 18:53:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-match-a-regex-query-in-a-CSV/m-p/429643#M122890</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2018-12-12T18:53:38Z</dc:date>
    </item>
    <item>
      <title>Re: How do I match a regex query in a CSV?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-match-a-regex-query-in-a-CSV/m-p/429644#M122891</link>
      <description>&lt;P&gt;This should provide better performance depending on the size of the lookup file:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| where
    [| inputlookup regexlookup.csv
    | eval matcher="match(subject,\"".regex."\")"
    | stats values(matcher) as search
    | eval search=mvjoin(search. " OR ")]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can append that to any search and it will add a where statement that is populated by a serious of matches from the regex in your lookup file.  If it's a massive lookup file this may cause some issues, but if it's not too big it should work alright.  You'll need to substitute the name of the lookup file where I have &lt;STRONG&gt;regexlookup.csv&lt;/STRONG&gt; and the name of the field you want to match on where I have &lt;STRONG&gt;subject&lt;/STRONG&gt;.&lt;/P&gt;

&lt;P&gt;Edit: I forgot to mention that you'll also need to make sure to update the &lt;STRONG&gt;regex&lt;/STRONG&gt; field in the match statement to match the field name of your regex in the lookup file too.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Dec 2018 19:13:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-match-a-regex-query-in-a-CSV/m-p/429644#M122891</guid>
      <dc:creator>dmarling</dc:creator>
      <dc:date>2018-12-12T19:13:25Z</dc:date>
    </item>
    <item>
      <title>Re: How do I match a regex query in a CSV?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-match-a-regex-query-in-a-CSV/m-p/429645#M122892</link>
      <description>&lt;P&gt;@JohnGilmour if this answer or the other one assisted you, please make sure to accept either of them as the accepted answer.  Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 05 Apr 2019 20:24:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-match-a-regex-query-in-a-CSV/m-p/429645#M122892</guid>
      <dc:creator>dmarling</dc:creator>
      <dc:date>2019-04-05T20:24:20Z</dc:date>
    </item>
    <item>
      <title>Re: How do I match a regex query in a CSV?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-match-a-regex-query-in-a-CSV/m-p/429646#M122893</link>
      <description>&lt;P&gt;I believe that you are looking for this, right?&lt;/P&gt;

&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/386488/regex-in-lookuptable.html"&gt;https://answers.splunk.com/answers/386488/regex-in-lookuptable.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 07 Apr 2019 13:59:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-match-a-regex-query-in-a-CSV/m-p/429646#M122893</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-04-07T13:59:51Z</dc:date>
    </item>
  </channel>
</rss>

