<?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 to Regex match literal \U in directory path in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-Regex-match-literal-U-in-directory-path/m-p/583622#M203236</link>
    <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;The actual directory is something like this, "&lt;SPAN&gt;C:\Users\abc\Downloads\file.exe"&lt;BR /&gt;&lt;BR /&gt;In your example, 4 backslashes would match literal 2 consecutive backslashes such as "\\" no?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 03 Feb 2022 18:20:28 GMT</pubDate>
    <dc:creator>frbuser</dc:creator>
    <dc:date>2022-02-03T18:20:28Z</dc:date>
    <item>
      <title>How to Regex match literal \U in directory path</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Regex-match-literal-U-in-directory-path/m-p/583603#M203230</link>
      <description>&lt;P&gt;I am trying to match a directory path including the string "\Users" but Splunk is throwing an error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex field=TargetFilename "C:\\Users\\\w+\\AppData\\(?&amp;lt;File_Dir&amp;gt;.*)\."&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;Error in 'rex' command: Encountered the following error while compiling the regex 'C:\Users\\w+\AppData\(?&amp;lt;File_Dir&amp;gt;.*)\.': Regex: PCRE does not support \L, \l, \N{name}, \U, or \u.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;How can I literally match the path?&lt;/P&gt;</description>
      <pubDate>Thu, 03 Feb 2022 17:04:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Regex-match-literal-U-in-directory-path/m-p/583603#M203230</guid>
      <dc:creator>frbuser</dc:creator>
      <dc:date>2022-02-03T17:04:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to Regex match literal \U in directory path</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Regex-match-literal-U-in-directory-path/m-p/583607#M203231</link>
      <description>&lt;P&gt;Splunk rex requires you to double up backslashes when trying to escape them&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval TargetFilename="C:\\Users\\abc\\AppData\\tom.**bleep**.harry"
| rex field=TargetFilename "C:\\\\Users\\\\\w+\\\\AppData\\\\(?&amp;lt;File_Dir&amp;gt;.*)\."&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 03 Feb 2022 17:12:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Regex-match-literal-U-in-directory-path/m-p/583607#M203231</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-02-03T17:12:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to Regex match literal \U in directory path</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Regex-match-literal-U-in-directory-path/m-p/583622#M203236</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;The actual directory is something like this, "&lt;SPAN&gt;C:\Users\abc\Downloads\file.exe"&lt;BR /&gt;&lt;BR /&gt;In your example, 4 backslashes would match literal 2 consecutive backslashes such as "\\" no?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Feb 2022 18:20:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Regex-match-literal-U-in-directory-path/m-p/583622#M203236</guid>
      <dc:creator>frbuser</dc:creator>
      <dc:date>2022-02-03T18:20:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to Regex match literal \U in directory path</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Regex-match-literal-U-in-directory-path/m-p/583624#M203238</link>
      <description>&lt;P&gt;No, you need 4 backslashes to match with 1 backslash&lt;/P&gt;&lt;P&gt;That is a runanywhere example, just copy it into a search in splunk and look at the _raw field and the result&lt;/P&gt;</description>
      <pubDate>Thu, 03 Feb 2022 18:36:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Regex-match-literal-U-in-directory-path/m-p/583624#M203238</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-02-03T18:36:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to Regex match literal \U in directory path</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Regex-match-literal-U-in-directory-path/m-p/583626#M203240</link>
      <description>&lt;P&gt;Ok I see that.&amp;nbsp;&lt;/P&gt;&lt;P&gt;But how come in your eval statement you needed only 2 backslashes for 1 literal backslash?&lt;BR /&gt;&lt;BR /&gt;I also tried changing it to one literal backslash in the eval and it still produce 1 literal backslash in the resulting value?&lt;/P&gt;</description>
      <pubDate>Thu, 03 Feb 2022 18:52:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Regex-match-literal-U-in-directory-path/m-p/583626#M203240</guid>
      <dc:creator>frbuser</dc:creator>
      <dc:date>2022-02-03T18:52:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to Regex match literal \U in directory path</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Regex-match-literal-U-in-directory-path/m-p/583632#M203242</link>
      <description>&lt;P&gt;The backslash has to be escaped with a backslash in a string (for the eval).&lt;/P&gt;&lt;P&gt;Look at the _raw field created by the search, it only has single backslashes in, just like your data.&lt;/P&gt;&lt;P&gt;For the rex, the string is passed through as a string and has to be escaped a second time, hence the doubling up.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Feb 2022 19:43:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Regex-match-literal-U-in-directory-path/m-p/583632#M203242</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-02-03T19:43:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to Regex match literal \U in directory path</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Regex-match-literal-U-in-directory-path/m-p/583658#M203247</link>
      <description>&lt;P&gt;There are two levels of escaping in play here.&lt;/P&gt;&lt;P&gt;If you just do "\\" i&amp;nbsp; a regex definition, splunk parsing the search and creating the string variable representing the regex will escape the backslash. That's the first level of escaping.&lt;/P&gt;&lt;P&gt;Thus if you do "\\\\" splunk creates a string consisting of two consecutive backslashes.&lt;/P&gt;&lt;P&gt;Now this string is getting supplied to the regex processor which also needs the backslash to be escaped to be treated as a literal backslash character.&lt;/P&gt;&lt;P&gt;So you need "\\\\" to be properly escaped (twice) in order to match single backslash character.&lt;/P&gt;&lt;P&gt;With eval you have only one level of escaping since you're only building a string, not processing regex afterwards.&lt;/P&gt;&lt;P&gt;Just be glad that you're not trying to write a bash script. Proper escaping when you want to supply the arguments somewhere can give you a migraine XD&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Feb 2022 22:34:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Regex-match-literal-U-in-directory-path/m-p/583658#M203247</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-02-03T22:34:26Z</dc:date>
    </item>
  </channel>
</rss>

