<?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 use regex to escape a backslash? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-regex-to-escape-a-backslash/m-p/381488#M111578</link>
    <description>&lt;P&gt;I don't see your regex working in regex101 with the sample provided. This regex matches your sample in regex101...&lt;BR /&gt;
    UserName\(?P&lt;USERNAME&gt;[^"]*)&lt;/USERNAME&gt;&lt;/P&gt;

&lt;P&gt;so perhaps this would work in Splunk...&lt;BR /&gt;
    rex field=_raw "UserName\(?P&lt;USERNAME&gt;[^"]*)"&lt;/USERNAME&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 13 Feb 2019 15:58:55 GMT</pubDate>
    <dc:creator>mydog8it</dc:creator>
    <dc:date>2019-02-13T15:58:55Z</dc:date>
    <item>
      <title>How do you use regex to escape a backslash?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-regex-to-escape-a-backslash/m-p/381485#M111575</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have the following regex which works on regex101, but gives me an error when I try and use this within a Splunk query. Not sure if it's the fact that Im trying to escape the backslash that's causing the issue.&lt;/P&gt;

&lt;P&gt;I have the field;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"UserName\a123456"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And I want to extract this into a field called NewUserName where it equals everything after the \ and up to closing quotes. So&lt;/P&gt;

&lt;P&gt;NewUserName should be;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;a123456
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;As I said, it works on Regex101 with the following;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"ADMIN\\*(?P[^"]*)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But when I try it in Splunk via;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=_raw "ADMIN\\*(?P[^"]*)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I get the error;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Mismatched ']' 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any ideas?&lt;/P&gt;</description>
      <pubDate>Wed, 13 Feb 2019 15:30:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-regex-to-escape-a-backslash/m-p/381485#M111575</guid>
      <dc:creator>jacqu3sy</dc:creator>
      <dc:date>2019-02-13T15:30:32Z</dc:date>
    </item>
    <item>
      <title>Re: How do you use regex to escape a backslash?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-regex-to-escape-a-backslash/m-p/381486#M111576</link>
      <description>&lt;P&gt;Hi @jacqu3sy&lt;/P&gt;

&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
   | eval msg="UserName\a123456" | rex field=msg "\\\(?P&amp;lt;NewUserName&amp;gt;.*)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Feb 2019 15:38:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-regex-to-escape-a-backslash/m-p/381486#M111576</guid>
      <dc:creator>vnravikumar</dc:creator>
      <dc:date>2019-02-13T15:38:50Z</dc:date>
    </item>
    <item>
      <title>Re: How do you use regex to escape a backslash?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-regex-to-escape-a-backslash/m-p/381487#M111577</link>
      <description>&lt;P&gt;Thanks. That worked. Not sure why it needs 3 backslashes though?! Think thats what caught me out. And could you explain what the P after the ? is for?&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Feb 2019 15:53:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-regex-to-escape-a-backslash/m-p/381487#M111577</guid>
      <dc:creator>jacqu3sy</dc:creator>
      <dc:date>2019-02-13T15:53:15Z</dc:date>
    </item>
    <item>
      <title>Re: How do you use regex to escape a backslash?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-regex-to-escape-a-backslash/m-p/381488#M111578</link>
      <description>&lt;P&gt;I don't see your regex working in regex101 with the sample provided. This regex matches your sample in regex101...&lt;BR /&gt;
    UserName\(?P&lt;USERNAME&gt;[^"]*)&lt;/USERNAME&gt;&lt;/P&gt;

&lt;P&gt;so perhaps this would work in Splunk...&lt;BR /&gt;
    rex field=_raw "UserName\(?P&lt;USERNAME&gt;[^"]*)"&lt;/USERNAME&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Feb 2019 15:58:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-regex-to-escape-a-backslash/m-p/381488#M111578</guid>
      <dc:creator>mydog8it</dc:creator>
      <dc:date>2019-02-13T15:58:55Z</dc:date>
    </item>
    <item>
      <title>Re: How do you use regex to escape a backslash?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-regex-to-escape-a-backslash/m-p/381489#M111579</link>
      <description>&lt;P&gt;(?P&amp;lt;&amp;gt;) is a named group which stores the extracted value.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Feb 2019 16:08:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-regex-to-escape-a-backslash/m-p/381489#M111579</guid>
      <dc:creator>vnravikumar</dc:creator>
      <dc:date>2019-02-13T16:08:23Z</dc:date>
    </item>
    <item>
      <title>Re: How do you use regex to escape a backslash?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-regex-to-escape-a-backslash/m-p/381490#M111580</link>
      <description>&lt;P&gt;The &lt;CODE&gt;P&lt;/CODE&gt; is not necessary in Splunk's implementation of RegEx, but it is harmless (and distracting).  I never use it.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Feb 2019 16:13:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-regex-to-escape-a-backslash/m-p/381490#M111580</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-02-13T16:13:06Z</dc:date>
    </item>
    <item>
      <title>Re: How do you use regex to escape a backslash?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-regex-to-escape-a-backslash/m-p/381491#M111581</link>
      <description>&lt;P&gt;I think this should work as it will only pick the string in format "UserName\a123456" and not any string that starts with backslash :-&lt;/P&gt;

&lt;P&gt;rex field =_raw "^".&lt;EM&gt;\(?P.&lt;/EM&gt;)\""&lt;/P&gt;</description>
      <pubDate>Sun, 17 Feb 2019 11:50:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-regex-to-escape-a-backslash/m-p/381491#M111581</guid>
      <dc:creator>kushagra9120</dc:creator>
      <dc:date>2019-02-17T11:50:59Z</dc:date>
    </item>
    <item>
      <title>Re: How do you use regex to escape a backslash?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-regex-to-escape-a-backslash/m-p/506818#M141773</link>
      <description>&lt;P&gt;Great , ! Thank you so much.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jul 2020 06:16:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-regex-to-escape-a-backslash/m-p/506818#M141773</guid>
      <dc:creator>Ganesh_Udar</dc:creator>
      <dc:date>2020-07-01T06:16:43Z</dc:date>
    </item>
  </channel>
</rss>

