<?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 Regex Help Needed in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Regex-Help-Needed/m-p/231235#M68581</link>
    <description>&lt;P&gt;I am not an expert with regex and I am trying to extract a field name= First, Last out of the following string&lt;/P&gt;

&lt;P&gt;user=LDAP://Server OU=Typical,OU=Users,OU=Branch,DC=domain,DC=com/First\, Last&lt;/P&gt;

&lt;P&gt;Any help is appreciated &lt;/P&gt;</description>
    <pubDate>Mon, 27 Jun 2016 19:04:25 GMT</pubDate>
    <dc:creator>ttchorz</dc:creator>
    <dc:date>2016-06-27T19:04:25Z</dc:date>
    <item>
      <title>Regex Help Needed</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Help-Needed/m-p/231235#M68581</link>
      <description>&lt;P&gt;I am not an expert with regex and I am trying to extract a field name= First, Last out of the following string&lt;/P&gt;

&lt;P&gt;user=LDAP://Server OU=Typical,OU=Users,OU=Branch,DC=domain,DC=com/First\, Last&lt;/P&gt;

&lt;P&gt;Any help is appreciated &lt;/P&gt;</description>
      <pubDate>Mon, 27 Jun 2016 19:04:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Help-Needed/m-p/231235#M68581</guid>
      <dc:creator>ttchorz</dc:creator>
      <dc:date>2016-06-27T19:04:25Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Help Needed</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Help-Needed/m-p/231236#M68582</link>
      <description>&lt;P&gt;This should do it.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex "DC=\w+\/(?&amp;lt;name&amp;gt;[^\\]+)\\, (?&amp;lt;last&amp;gt;\w+)" | ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;BTW, regex101.com is your friend.  &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jun 2016 19:14:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Help-Needed/m-p/231236#M68582</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2016-06-27T19:14:16Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Help Needed</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Help-Needed/m-p/231237#M68583</link>
      <description>&lt;P&gt;Hi Rich,&lt;/P&gt;

&lt;P&gt;I was able to understand the regex except the point where we added [^\] after name capturing. The other character '\' after First could be understood to be escaped properly but why [^\]&lt;/P&gt;

&lt;P&gt;Thanks !&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jun 2016 19:34:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Help-Needed/m-p/231237#M68583</guid>
      <dc:creator>drumster88</dc:creator>
      <dc:date>2016-06-27T19:34:17Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Help Needed</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Help-Needed/m-p/231238#M68584</link>
      <description>&lt;P&gt;Is there an efficient way to extract the two values to one field ? Lets say User(name, last) ? Or should the fields be merged after being extracted? &lt;/P&gt;</description>
      <pubDate>Mon, 27 Jun 2016 19:41:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Help-Needed/m-p/231238#M68584</guid>
      <dc:creator>ttchorz</dc:creator>
      <dc:date>2016-06-27T19:41:46Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Help Needed</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Help-Needed/m-p/231239#M68585</link>
      <description>&lt;P&gt;I read the '\' as a delimiter rather than an escaped comma.  Try this regex to get the entire name in one field.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex "DC=\w+\/(?&amp;lt;name&amp;gt;[\w, \\]+)" | ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will probably leave the escaped comma in the &lt;CODE&gt;name&lt;/CODE&gt; field.  I've been unsuccessful removing it.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jun 2016 19:56:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Help-Needed/m-p/231239#M68585</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2016-06-27T19:56:50Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Help Needed</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Help-Needed/m-p/231240#M68586</link>
      <description>&lt;P&gt;that works but it also captures "\" after name and before the comma so it look like "name\, last" any way of removing  "\" ?&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jun 2016 20:04:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Help-Needed/m-p/231240#M68586</guid>
      <dc:creator>ttchorz</dc:creator>
      <dc:date>2016-06-27T20:04:17Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Help Needed</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Help-Needed/m-p/231241#M68587</link>
      <description>&lt;P&gt;Like I said in my last comment, I've been unsuccessful at removing the '\'.  I just tried something else that worked.  Add this after the above &lt;CODE&gt;rex&lt;/CODE&gt; command.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=name mode=sed "s/\\\//g" | ...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Jun 2016 20:14:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Help-Needed/m-p/231241#M68587</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2016-06-27T20:14:30Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Help Needed</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Help-Needed/m-p/231242#M68588</link>
      <description>&lt;P&gt;I would extract it as two separate fields like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;DC\=com\/(?&amp;lt;first&amp;gt;[^\\]*)\\\,\s*(?&amp;lt;last&amp;gt;[^\$]*)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and than create a calculated field user that puts them together, that way you can search efficiently on the complete name or on the first or last name.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jul 2016 09:58:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Help-Needed/m-p/231242#M68588</guid>
      <dc:creator>aholzel</dc:creator>
      <dc:date>2016-07-01T09:58:21Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Help Needed</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Help-Needed/m-p/231243#M68589</link>
      <description>&lt;P&gt;Well, sort of but you get the yucky stuff in the middle. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;DC=\w+\/(?&amp;lt;name&amp;gt;[^\\]+\\, \w+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That would give you &lt;CODE&gt;First\, Last&lt;/CODE&gt; which is ... probably not quite what you desire.  You can't split a single field up like what you want... no, you can't &lt;EM&gt;combine&lt;/EM&gt; two individual things into one field?  Either way, I'm not aware of a way to do that, so just combine 'em at the end.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; ... | rex "DC=\w+\/(?&amp;lt;name&amp;gt;[^\\]+)\\, (?&amp;lt;last&amp;gt;\w+)" | eval FullName=name." ".last | ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;There's a zillion ways to accomplish that, but if I didn't fat finger it there's one.  It's fragile, though - if you have an event without a first name, well, you'll not have a FullName either.  &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;  More help can be given if required, but if it works for your needs then it's probably good enough.&lt;/P&gt;

&lt;P&gt;If this or the other answer resolves your needs (you can apply my mini-extra-solution to either!), could you please mark one as the answer to help everyone else who stumbles across this answer later?&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jul 2016 13:07:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Help-Needed/m-p/231243#M68589</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2016-07-01T13:07:01Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Help Needed</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Help-Needed/m-p/231244#M68590</link>
      <description>&lt;P&gt;Thanks all! All of your answers were helpful and let me accomplish what I was looking for. &lt;/P&gt;</description>
      <pubDate>Fri, 01 Jul 2016 16:11:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Help-Needed/m-p/231244#M68590</guid>
      <dc:creator>ttchorz</dc:creator>
      <dc:date>2016-07-01T16:11:16Z</dc:date>
    </item>
  </channel>
</rss>

