<?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 you filter search results based on a variable...? in Security</title>
    <link>https://community.splunk.com/t5/Security/How-do-you-filter-search-results-based-on-a-variable/m-p/420628#M9988</link>
    <description>&lt;P&gt;Hi Kail, thanks for your reply.&lt;/P&gt;

&lt;P&gt;Apologies, I may communicated my intentions incorrectly. I do not need to specify whether the user is a student or staff, I just need to filter out any username that contains numbers. I have thousands of users, therfore it would need to be a simple variable and not specifying individual usernames. &lt;/P&gt;

&lt;P&gt;For example: If username contains numbers, do not include in the search result. &lt;/P&gt;

&lt;P&gt;Thanks for your help though.&lt;/P&gt;</description>
    <pubDate>Mon, 04 Mar 2019 13:07:42 GMT</pubDate>
    <dc:creator>danfinan</dc:creator>
    <dc:date>2019-03-04T13:07:42Z</dc:date>
    <item>
      <title>How do you filter search results based on a variable...?</title>
      <link>https://community.splunk.com/t5/Security/How-do-you-filter-search-results-based-on-a-variable/m-p/420625#M9985</link>
      <description>&lt;P&gt;Hi all, &lt;/P&gt;

&lt;P&gt;Hopefully my title makes sense, I'm trying to filter my results depending on the format of the username. I'm pumping in the logs from a web filter into Splunk and I want to separate out users depending on whether their username contains numbers or not. For example: andrew.smith or joe.blogs123 &lt;/P&gt;

&lt;P&gt;I'd like to be able to create a condition where I tell Splunk: "If username contains [digits]" then only display those search results.&lt;/P&gt;

&lt;P&gt;Is this possible within Splunk?&lt;/P&gt;

&lt;P&gt;Any help is greatly appreciated! Thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;/P&gt;

&lt;P&gt;Edited to avoid confusion. &lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2019 12:31:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/How-do-you-filter-search-results-based-on-a-variable/m-p/420625#M9985</guid>
      <dc:creator>danfinan</dc:creator>
      <dc:date>2019-03-04T12:31:47Z</dc:date>
    </item>
    <item>
      <title>Re: How do you filter search results based on a variable...?</title>
      <link>https://community.splunk.com/t5/Security/How-do-you-filter-search-results-based-on-a-variable/m-p/420626#M9986</link>
      <description>&lt;P&gt;Hi @danfinan&lt;/P&gt;

&lt;P&gt;Try this and let me know&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval username ="joe.blogs123" 
| regex username ="\d"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;OR&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval username ="joe.blogs123,andrew.smith" 
| makemv delim="," username 
| mvexpand username 
| eval result= if(match(username,"\d"),"student","staff")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 04 Mar 2019 12:42:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/How-do-you-filter-search-results-based-on-a-variable/m-p/420626#M9986</guid>
      <dc:creator>vnravikumar</dc:creator>
      <dc:date>2019-03-04T12:42:03Z</dc:date>
    </item>
    <item>
      <title>Re: How do you filter search results based on a variable...?</title>
      <link>https://community.splunk.com/t5/Security/How-do-you-filter-search-results-based-on-a-variable/m-p/420627#M9987</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;You can try to use the &lt;CODE&gt;match&lt;/CODE&gt; function like in this example and filter on the new field created:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval username ="joe.blogs132"
| append 
    [| makeresults 
| eval username ="andrew.smith"]
| eval Type = if(match(username,"\d"),"Student","Staff")
| where Type = "Student"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Like that you can chose if you want to match a student or a staff, as you want.&lt;/P&gt;

&lt;P&gt;Let me know if it help you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Kail&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2019 12:58:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/How-do-you-filter-search-results-based-on-a-variable/m-p/420627#M9987</guid>
      <dc:creator>KailA</dc:creator>
      <dc:date>2019-03-04T12:58:43Z</dc:date>
    </item>
    <item>
      <title>Re: How do you filter search results based on a variable...?</title>
      <link>https://community.splunk.com/t5/Security/How-do-you-filter-search-results-based-on-a-variable/m-p/420628#M9988</link>
      <description>&lt;P&gt;Hi Kail, thanks for your reply.&lt;/P&gt;

&lt;P&gt;Apologies, I may communicated my intentions incorrectly. I do not need to specify whether the user is a student or staff, I just need to filter out any username that contains numbers. I have thousands of users, therfore it would need to be a simple variable and not specifying individual usernames. &lt;/P&gt;

&lt;P&gt;For example: If username contains numbers, do not include in the search result. &lt;/P&gt;

&lt;P&gt;Thanks for your help though.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2019 13:07:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/How-do-you-filter-search-results-based-on-a-variable/m-p/420628#M9988</guid>
      <dc:creator>danfinan</dc:creator>
      <dc:date>2019-03-04T13:07:42Z</dc:date>
    </item>
    <item>
      <title>Re: How do you filter search results based on a variable...?</title>
      <link>https://community.splunk.com/t5/Security/How-do-you-filter-search-results-based-on-a-variable/m-p/420629#M9989</link>
      <description>&lt;P&gt;Ok so something like that I guess:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Base search 
| where NOT match(username,"\d")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;or with @vnravikumar solution (the &lt;CODE&gt;regex&lt;/CODE&gt; one)&lt;/P&gt;

&lt;P&gt;Unfortunately, you can not do it directly in the base search.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2019 13:17:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/How-do-you-filter-search-results-based-on-a-variable/m-p/420629#M9989</guid>
      <dc:creator>KailA</dc:creator>
      <dc:date>2019-03-04T13:17:20Z</dc:date>
    </item>
    <item>
      <title>Re: How do you filter search results based on a variable...?</title>
      <link>https://community.splunk.com/t5/Security/How-do-you-filter-search-results-based-on-a-variable/m-p/420630#M9990</link>
      <description>&lt;P&gt;You've got it! Thank you very much, just tested and that's exactyl what I needed. You're a star! &lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2019 13:24:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/How-do-you-filter-search-results-based-on-a-variable/m-p/420630#M9990</guid>
      <dc:creator>danfinan</dc:creator>
      <dc:date>2019-03-04T13:24:15Z</dc:date>
    </item>
  </channel>
</rss>

