<?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: Splunk Regex never works when entered second folder in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Splunk-Regex-never-works-when-entered-second-folder/m-p/706850#M239150</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/274894"&gt;@Cramery_&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;could you share a sample of your complete logs (aventually anonymized)?&lt;/P&gt;&lt;P&gt;Anyway, when there's a backslash, it's always a problem because you need to add more backslashes than usual on regex101.com.&lt;/P&gt;&lt;P&gt;Do you need to use the regex in a search or in conf files?&lt;/P&gt;&lt;P&gt;if in conf files, use the number of backslashes that you use in regex101, if in a search add one backslash.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
    <pubDate>Mon, 16 Dec 2024 08:14:34 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2024-12-16T08:14:34Z</dc:date>
    <item>
      <title>Splunk Regex never works when entered second folder</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-Regex-never-works-when-entered-second-folder/m-p/706847#M239148</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;So I ran into a very odd and specific issue. I trx to regex-Filter a field, lets call it "parent". The field has the following structure: (not actual, the field I wanna regex, but easier to show the issue, so other options like "use .* or something wont work)&lt;BR /&gt;C:\\Windows\\System32\\test\\&lt;BR /&gt;I try to regex this field like:&lt;BR /&gt;"C:\\\\Windows\\\\System32\\\\test\\\\"&lt;BR /&gt;This does not work&lt;BR /&gt;&lt;BR /&gt;But as soon as I delete this second folder&lt;BR /&gt;"C:\\\\Windows\\\\.*\\\\test\\\\"&lt;BR /&gt;it works.&lt;BR /&gt;&lt;BR /&gt;And this will be over all fields, no matter which field with a path I take, as soon as I enter this second folder, it will immediately stop working. I also tried to add different special characters, all numbers and letters, space, tab etc. also tried to change the "\\\\", Adding ".*System32.*" but nothing works out.&lt;BR /&gt;&lt;BR /&gt;Someone else ever ran into this issue and got a solution?&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2024 07:57:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-Regex-never-works-when-entered-second-folder/m-p/706847#M239148</guid>
      <dc:creator>Cramery_</dc:creator>
      <dc:date>2024-12-16T07:57:10Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk Regex never works when entered second folder</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-Regex-never-works-when-entered-second-folder/m-p/706850#M239150</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/274894"&gt;@Cramery_&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;could you share a sample of your complete logs (aventually anonymized)?&lt;/P&gt;&lt;P&gt;Anyway, when there's a backslash, it's always a problem because you need to add more backslashes than usual on regex101.com.&lt;/P&gt;&lt;P&gt;Do you need to use the regex in a search or in conf files?&lt;/P&gt;&lt;P&gt;if in conf files, use the number of backslashes that you use in regex101, if in a search add one backslash.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2024 08:14:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-Regex-never-works-when-entered-second-folder/m-p/706850#M239150</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2024-12-16T08:14:34Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk Regex never works when entered second folder</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-Regex-never-works-when-entered-second-folder/m-p/706985#M239174</link>
      <description>&lt;P&gt;Like&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;says, matching backslash is tricky. &amp;nbsp;This is because backslash is used as an escape character so special characters can be used as literal. &amp;nbsp;This applies to backslash itself as well. &amp;nbsp;This needs to be taken into consideration whenever an interpreter/compiler uses backslash as an escape character.&lt;/P&gt;&lt;P&gt;When you run rex (or any function that uses regex) in a search command, two interpreters act on the string in between double quotes: the regex engine and SPL interpreter. &amp;nbsp;As such, to match two consecutive backslashes, you need 8 backslashes instead of 4. &amp;nbsp;Try this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults format=csv data="myregex
C:\\\\Windows\\\\System32\\\\test\\\\
C:\\\\\\\\Windows\\\\\\\\System32\\\\\\\\test\\\\\\\\"
| eval parent = "C:\\\\Windows\\\\System32\\\\test\\\\"
| eval match_or_not = if(match(parent, myregex), "yes", "no")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The result is&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;match_or_not&lt;/TD&gt;&lt;TD&gt;myregex&lt;/TD&gt;&lt;TD&gt;parent&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;TD&gt;C:\\Windows\\System32\\test\\&lt;/TD&gt;&lt;TD&gt;C:\\Windows\\System32\\test\\&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;yes&lt;/TD&gt;&lt;TD&gt;C:\\\\Windows\\\\System32\\\\test\\\\&lt;/TD&gt;&lt;TD&gt;C:\\Windows\\System32\\test\\&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;This test illustrates the same thing:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults format=csv data="parent
C:\\\\Windows\\\\System32\\\\test\\\\"
| eval match_or_not1 = if(match(parent, "C:\\\\\\\\Windows\\\\\\\\System32\\\\\\\\test\\\\\\\\"), "yes", "no")
| eval match_or_not2 = if(match(parent, "C:\\\\Windows\\\\System32\\\\test\\\\"), "yes", "no")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;match_or_not1&lt;/TD&gt;&lt;TD&gt;match_or_not2&lt;/TD&gt;&lt;TD&gt;parent&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;yes&lt;/TD&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;TD&gt;C:\\Windows\\System32\\test\\&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;If you look around, SPL is not the only interpreter that interprets strings in between double quotes. &amp;nbsp;For example, in order to produce your test string "&lt;SPAN&gt;C:\\Windows\\System32\\test\\" using echo command in shell, you use&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;% echo "C:\\\\\\Windows\\\\\\System32\\\\\\\\test\\\\\\"
#         ^6x          ^6x           ^7x         ^6x
C:\\Windows\\System32\\test\\&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will leave it as homework to figure out why one segment needs 7 backslashes.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Dec 2024 03:35:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-Regex-never-works-when-entered-second-folder/m-p/706985#M239174</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2024-12-17T03:35:56Z</dc:date>
    </item>
  </channel>
</rss>

