<?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 Expression to Extract a username out after matching a Specific String of Characters in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-a-username-out-after-matching-a/m-p/302588#M91074</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;

&lt;P&gt;I am attempting to do a field extraction using regular expression and I am having some trouble.  I have the following syslog message below from a test Juniper firewall.  The username I am logging in with is jdoe-2fa and I have other users that have usernames as well with "-2fa" in their username.  What I am trying to do is create a regular expression that searches for -2fa but extracts the actual full username jdoe-2fa so that I can create a field called user.&lt;/P&gt;

&lt;P&gt;Jan  9 07:35:16 192.168.1.254 firewall001: NetScreen device_id=firewall001  [Root]system-warning-00515: Admin user jdoe-2fa/904744 has logged on via SSH from 192.168.1.100:53429 (2018-01-09 15:35:15)&lt;/P&gt;</description>
    <pubDate>Thu, 11 Jan 2018 16:18:50 GMT</pubDate>
    <dc:creator>zzaveri</dc:creator>
    <dc:date>2018-01-11T16:18:50Z</dc:date>
    <item>
      <title>Regular Expression to Extract a username out after matching a Specific String of Characters</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-a-username-out-after-matching-a/m-p/302588#M91074</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;

&lt;P&gt;I am attempting to do a field extraction using regular expression and I am having some trouble.  I have the following syslog message below from a test Juniper firewall.  The username I am logging in with is jdoe-2fa and I have other users that have usernames as well with "-2fa" in their username.  What I am trying to do is create a regular expression that searches for -2fa but extracts the actual full username jdoe-2fa so that I can create a field called user.&lt;/P&gt;

&lt;P&gt;Jan  9 07:35:16 192.168.1.254 firewall001: NetScreen device_id=firewall001  [Root]system-warning-00515: Admin user jdoe-2fa/904744 has logged on via SSH from 192.168.1.100:53429 (2018-01-09 15:35:15)&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2018 16:18:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-a-username-out-after-matching-a/m-p/302588#M91074</guid>
      <dc:creator>zzaveri</dc:creator>
      <dc:date>2018-01-11T16:18:50Z</dc:date>
    </item>
    <item>
      <title>Re: Regular Expression to Extract a username out after matching a Specific String of Characters</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-a-username-out-after-matching-a/m-p/302589#M91075</link>
      <description>&lt;P&gt;Run anywhere example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval _raw="Jan 9 07:35:16 192.168.1.254 firewall001: NetScreen device_id=firewall001 [Root]system-warning-00515: Admin user jdoe-2fa/904744 has logged on via SSH from 192.168.1.100:53429 (2018-01-09 15:35:15)"
| rex "user (?&amp;lt;full_user&amp;gt;(?&amp;lt;no_2fa_user&amp;gt;[^\/]+?)(-2fa)?)\/"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Jan 2018 20:15:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-a-username-out-after-matching-a/m-p/302589#M91075</guid>
      <dc:creator>micahkemp</dc:creator>
      <dc:date>2018-01-11T20:15:59Z</dc:date>
    </item>
    <item>
      <title>Re: Regular Expression to Extract a username out after matching a Specific String of Characters</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-a-username-out-after-matching-a/m-p/302590#M91076</link>
      <description>&lt;P&gt;Try this &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=&amp;lt;your_index&amp;gt;   | rex field=_raw “user\s(?&amp;lt;user&amp;gt;[^\/]+)” | search user=*-2fa
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Let me know if this helps&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2018 20:41:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-a-username-out-after-matching-a/m-p/302590#M91076</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2018-01-11T20:41:11Z</dc:date>
    </item>
    <item>
      <title>Re: Regular Expression to Extract a username out after matching a Specific String of Characters</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-a-username-out-after-matching-a/m-p/302591#M91077</link>
      <description>&lt;P&gt;Actually this seems closer to what was asked for. At first I was thinking it was asked to separate the &lt;CODE&gt;-2fa&lt;/CODE&gt; from the rest of the username, but at second glance that doesn’t appear to be the case.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2018 20:47:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-a-username-out-after-matching-a/m-p/302591#M91077</guid>
      <dc:creator>micahkemp</dc:creator>
      <dc:date>2018-01-11T20:47:54Z</dc:date>
    </item>
    <item>
      <title>Re: Regular Expression to Extract a username out after matching a Specific String of Characters</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-a-username-out-after-matching-a/m-p/302592#M91078</link>
      <description>&lt;P&gt;No worries happens &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; You are doing quite well .conf18 pass for this month is mostly yours ! &lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2018 20:55:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-a-username-out-after-matching-a/m-p/302592#M91078</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2018-01-11T20:55:53Z</dc:date>
    </item>
    <item>
      <title>Re: Regular Expression to Extract a username out after matching a Specific String of Characters</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-a-username-out-after-matching-a/m-p/302593#M91079</link>
      <description>&lt;P&gt;I get the following message &lt;/P&gt;

&lt;P&gt;Error in 'SearchParser': Missing a search command before '^'. Error at position '55' of search query 'search index="indexname" | rex field=_raw “user\s(?[^\/]+)” |}'.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2018 21:02:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-a-username-out-after-matching-a/m-p/302593#M91079</guid>
      <dc:creator>zzaveri</dc:creator>
      <dc:date>2018-01-11T21:02:49Z</dc:date>
    </item>
    <item>
      <title>Re: Regular Expression to Extract a username out after matching a Specific String of Characters</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-a-username-out-after-matching-a/m-p/302594#M91080</link>
      <description>&lt;P&gt;What query are you running?put it in &lt;CODE&gt;101010&lt;/CODE&gt; sample code&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2018 21:15:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-a-username-out-after-matching-a/m-p/302594#M91080</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2018-01-11T21:15:28Z</dc:date>
    </item>
    <item>
      <title>Re: Regular Expression to Extract a username out after matching a Specific String of Characters</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-a-username-out-after-matching-a/m-p/302595#M91081</link>
      <description>&lt;P&gt;Your double quotes came across wrong.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=_raw "user\s(?&amp;lt;user&amp;gt;[^\/]+)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Jan 2018 21:21:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-a-username-out-after-matching-a/m-p/302595#M91081</guid>
      <dc:creator>micahkemp</dc:creator>
      <dc:date>2018-01-11T21:21:28Z</dc:date>
    </item>
    <item>
      <title>Re: Regular Expression to Extract a username out after matching a Specific String of Characters</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-a-username-out-after-matching-a/m-p/302596#M91082</link>
      <description>&lt;P&gt;Hopefully we'll both get to go and enjoy some beverages!&lt;/P&gt;

&lt;P&gt;It's basically this month or bust for me.  They'll put me back to work next month, so I won't have nearly as much time to post on answers.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2018 21:24:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-a-username-out-after-matching-a/m-p/302596#M91082</guid>
      <dc:creator>micahkemp</dc:creator>
      <dc:date>2018-01-11T21:24:50Z</dc:date>
    </item>
    <item>
      <title>Re: Regular Expression to Extract a username out after matching a Specific String of Characters</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-a-username-out-after-matching-a/m-p/302597#M91083</link>
      <description>&lt;P&gt;Yeah I hope so all the best !&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2018 21:35:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-a-username-out-after-matching-a/m-p/302597#M91083</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2018-01-11T21:35:26Z</dc:date>
    </item>
    <item>
      <title>Re: Regular Expression to Extract a username out after matching a Specific String of Characters</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-a-username-out-after-matching-a/m-p/302598#M91084</link>
      <description>&lt;P&gt;Thank you that resolved the issue.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 00:05:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-a-username-out-after-matching-a/m-p/302598#M91084</guid>
      <dc:creator>zzaveri</dc:creator>
      <dc:date>2018-01-12T00:05:21Z</dc:date>
    </item>
    <item>
      <title>Re: Regular Expression to Extract a username out after matching a Specific String of Characters</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-a-username-out-after-matching-a/m-p/302599#M91085</link>
      <description>&lt;P&gt;If the answer solved your issue, please accept it so the question looks resolved.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 00:08:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regular-Expression-to-Extract-a-username-out-after-matching-a/m-p/302599#M91085</guid>
      <dc:creator>micahkemp</dc:creator>
      <dc:date>2018-01-12T00:08:04Z</dc:date>
    </item>
  </channel>
</rss>

