<?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: negate a backslash in regex without negating other characters in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/negate-a-backslash-in-regex-without-negating-other-characters/m-p/197203#M56951</link>
    <description>&lt;P&gt;I didn't really understand you data, but the follwing &lt;CODE&gt;rex&lt;/CODE&gt; will extract the username part of a &lt;CODE&gt;domain\user&lt;/CODE&gt; type string. Assuming the field is called "domain_user" and contains the value &lt;CODE&gt;acme\bob&lt;/CODE&gt; &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex field = domain_user "[^\\\\]+\\\\(?&amp;lt;user&amp;gt;.*)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;should extract &lt;CODE&gt;bob&lt;/CODE&gt; into the field &lt;CODE&gt;user&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;/K&lt;/P&gt;

&lt;P&gt;EDIT: corrected the number of backslashes required.&lt;/P&gt;</description>
    <pubDate>Wed, 27 Aug 2014 19:21:27 GMT</pubDate>
    <dc:creator>kristian_kolb</dc:creator>
    <dc:date>2014-08-27T19:21:27Z</dc:date>
    <item>
      <title>negate a backslash in regex without negating other characters</title>
      <link>https://community.splunk.com/t5/Splunk-Search/negate-a-backslash-in-regex-without-negating-other-characters/m-p/197202#M56950</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I want to create a new field, from a string, showing the domain user, where the only constant is "\" which I don't want included.&lt;/P&gt;

&lt;P&gt;Sample input:&lt;/P&gt;

&lt;P&gt;(no field either side of "\" is predictable)&lt;/P&gt;

&lt;P&gt;12345\alice&lt;BR /&gt;
45632\__test_account__&lt;BR /&gt;
PC123\bob&lt;/P&gt;

&lt;P&gt;My search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="dc_report" | rex field=domain_user "(?&amp;lt;user&amp;gt;^.*\\(.*$))" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This results in unmatched parentheses. Is there a way to use &amp;amp;#92 (hmtl "\") instead of negation?&lt;/P&gt;

&lt;P&gt;The other route is to use the index of "\" and then select to the right. Unsure of what functions to use/how to use them. &lt;/P&gt;</description>
      <pubDate>Wed, 27 Aug 2014 18:32:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/negate-a-backslash-in-regex-without-negating-other-characters/m-p/197202#M56950</guid>
      <dc:creator>jdbtee</dc:creator>
      <dc:date>2014-08-27T18:32:56Z</dc:date>
    </item>
    <item>
      <title>Re: negate a backslash in regex without negating other characters</title>
      <link>https://community.splunk.com/t5/Splunk-Search/negate-a-backslash-in-regex-without-negating-other-characters/m-p/197203#M56951</link>
      <description>&lt;P&gt;I didn't really understand you data, but the follwing &lt;CODE&gt;rex&lt;/CODE&gt; will extract the username part of a &lt;CODE&gt;domain\user&lt;/CODE&gt; type string. Assuming the field is called "domain_user" and contains the value &lt;CODE&gt;acme\bob&lt;/CODE&gt; &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex field = domain_user "[^\\\\]+\\\\(?&amp;lt;user&amp;gt;.*)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;should extract &lt;CODE&gt;bob&lt;/CODE&gt; into the field &lt;CODE&gt;user&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;/K&lt;/P&gt;

&lt;P&gt;EDIT: corrected the number of backslashes required.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Aug 2014 19:21:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/negate-a-backslash-in-regex-without-negating-other-characters/m-p/197203#M56951</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2014-08-27T19:21:27Z</dc:date>
    </item>
    <item>
      <title>Re: negate a backslash in regex without negating other characters</title>
      <link>https://community.splunk.com/t5/Splunk-Search/negate-a-backslash-in-regex-without-negating-other-characters/m-p/197204#M56952</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Your solution still negates the 2nd "]" resulting in the error message "Regex: missing terminating ] for character class"&lt;/P&gt;</description>
      <pubDate>Wed, 27 Aug 2014 19:30:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/negate-a-backslash-in-regex-without-negating-other-characters/m-p/197204#M56952</guid>
      <dc:creator>jdbtee</dc:creator>
      <dc:date>2014-08-27T19:30:42Z</dc:date>
    </item>
    <item>
      <title>Re: negate a backslash in regex without negating other characters</title>
      <link>https://community.splunk.com/t5/Splunk-Search/negate-a-backslash-in-regex-without-negating-other-characters/m-p/197205#M56953</link>
      <description>&lt;P&gt;My solution, although not sure how cpu intensive this is.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="dc_report"| eval user=mvindex(split(domain_user,"\\"),1)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This splits the x\y on the "\" and then passes the output of the 2nd value (i.e. index starts at 0), using mvindex, to the variable "user".&lt;/P&gt;</description>
      <pubDate>Wed, 27 Aug 2014 19:32:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/negate-a-backslash-in-regex-without-negating-other-characters/m-p/197205#M56953</guid>
      <dc:creator>jdbtee</dc:creator>
      <dc:date>2014-08-27T19:32:20Z</dc:date>
    </item>
    <item>
      <title>Re: negate a backslash in regex without negating other characters</title>
      <link>https://community.splunk.com/t5/Splunk-Search/negate-a-backslash-in-regex-without-negating-other-characters/m-p/197206#M56954</link>
      <description>&lt;P&gt;I'd still like to see this done in regex, but it seems Splunk negates any type of parenthesis proceeding a negated backslash, where the online regex testers are unaffected.&lt;/P&gt;

&lt;P&gt;Do functions have a significant overhead compared to regex?&lt;/P&gt;</description>
      <pubDate>Wed, 27 Aug 2014 19:53:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/negate-a-backslash-in-regex-without-negating-other-characters/m-p/197206#M56954</guid>
      <dc:creator>jdbtee</dc:creator>
      <dc:date>2014-08-27T19:53:06Z</dc:date>
    </item>
    <item>
      <title>Re: negate a backslash in regex without negating other characters</title>
      <link>https://community.splunk.com/t5/Splunk-Search/negate-a-backslash-in-regex-without-negating-other-characters/m-p/197207#M56955</link>
      <description>&lt;P&gt;OOPS. The backslashes need to be escaped twice, i.e. four backslashes.&lt;/P&gt;

&lt;P&gt;The search language needs escaping &lt;CODE&gt;\\\\&lt;/CODE&gt; -&amp;gt; &lt;CODE&gt;\\&lt;/CODE&gt;&lt;BR /&gt;
then rex needs escaping as well &lt;CODE&gt;\\&lt;/CODE&gt; -&amp;gt; &lt;CODE&gt;\&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Profit!&lt;/P&gt;

&lt;P&gt;/K&lt;/P&gt;</description>
      <pubDate>Wed, 27 Aug 2014 21:07:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/negate-a-backslash-in-regex-without-negating-other-characters/m-p/197207#M56955</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2014-08-27T21:07:23Z</dc:date>
    </item>
  </channel>
</rss>

