<?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: Howto escape double quote in regex when using rex in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Howto-escape-double-quote-in-regex-when-using-rex/m-p/709215#M239691</link>
    <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;.&amp;nbsp;I am aware that I need to escape stuff, problem is I do not see where I might have missed one, I already escaped a lot, at least what was required on regex101.&lt;/P&gt;&lt;P&gt;It seems your solution works, will continue with that. Thanks!&lt;/P&gt;</description>
    <pubDate>Mon, 20 Jan 2025 08:49:32 GMT</pubDate>
    <dc:creator>jmartens</dc:creator>
    <dc:date>2025-01-20T08:49:32Z</dc:date>
    <item>
      <title>Howto escape double quote in regex when using rex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Howto-escape-double-quote-in-regex-when-using-rex/m-p/709211#M239689</link>
      <description>&lt;P&gt;I have the following regex that I (currently) use at search time (it will be a field extraction once I get it ironed out):&lt;/P&gt;&lt;PRE&gt;User\[(?:(?&amp;lt;SignOffDomain&amp;gt;[^\\]+)(?:\\))?(?&amp;lt;SignOffUsername&amp;gt;[^\]]+)[^\[]+\[\"(?&amp;lt;SignOffComment&amp;gt;[^\:]+)\:\s+(?&amp;lt;SignOffPrivilege&amp;gt;[^\"]+)&lt;/PRE&gt;&lt;P&gt;It seems to work OK on regex101:&amp;nbsp;&lt;A href="https://regex101.com/r/nGdKxQ/5" target="_blank" rel="noopener"&gt;https://regex101.com/r/nGdKxQ/5&lt;/A&gt; but fails when trying to parse in Splunk with the following error:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;Error in 'rex' command: Encountered the following error while compiling the regex 'User\[(?:(?&amp;lt;SignOffDomain&amp;gt;[^\]+)(?:\))?(?&amp;lt;SignOffUsername&amp;gt;[^\]]+)[^\[]+\["(?&amp;lt;SignOffComment&amp;gt;[^\:]+)\:\s+(?&amp;lt;SignOffPrivilege&amp;gt;[^\"]+)': Regex: missing closing parenthesis.&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;Any clue on what I need to escape additionally perhaps?&lt;/P&gt;&lt;P&gt;For testing I created the following sample:&lt;/P&gt;&lt;PRE&gt;| makeresults count=2&lt;BR /&gt;| streamstats count&lt;BR /&gt;| eval _raw=if((count%2) == 1, "2025-01-20 08:43:11 Local0 Info 08:43:11:347 HAL-TRT-SN1701 DOMAIN\firstname0.lastname0|4832|TXA HIPAA [1m]HIPAALogging: User[DOMAIN\firstname0.lastname0], Comment[\"Successfully authenticated user with privilege: A_Dummy_Privilege\"], PatientId[PatientIdX], PlanUID[PlanLabel:PlabnLabelX,PlanInstanceUID:PlanInstanceUIDX", "2025-01-20 07:54:42 Local0 Info 07:54:41:911 HAL-TRT-SN1701 domain\firstanme2.lastname2|4832|TXA HIPAA [1m]HIPAALogging: User[firstname1.lastname1], Comment[\"Successfully authenticated user with privilege: AnotherPrivilege\"], PatientId[], PlanUID[], Right[True]")&lt;BR /&gt;| rex field="_raw" "User\[(?:(?&amp;lt;SignOffDomain&amp;gt;[^\\]+)(?:\\))?(?&amp;lt;SignOffUsername&amp;gt;[^\]]+)[^\[]+\[\"(?&amp;lt;SignOffComment&amp;gt;[^\:]+)\:\s+(?&amp;lt;SignOffPrivilege&amp;gt;[^\"]+)"&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jan 2025 08:46:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Howto-escape-double-quote-in-regex-when-using-rex/m-p/709211#M239689</guid>
      <dc:creator>jmartens</dc:creator>
      <dc:date>2025-01-20T08:46:02Z</dc:date>
    </item>
    <item>
      <title>Re: Howto escape double quote in regex when using rex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Howto-escape-double-quote-in-regex-when-using-rex/m-p/709214#M239690</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/138072"&gt;@jmartens&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;this is a bug that I noticed to Splunk Support but they said that's ok!&lt;/P&gt;&lt;P&gt;Anyway, when you need to escape a backslash in Splunk in a regex that runs in regex101, you have to add one ot two additional backslashes in Splunk every time you jave a backslash.&lt;/P&gt;&lt;P&gt;So try&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;pre&amp;gt;User\[(?:(?&amp;lt;SignOffDomain&amp;gt;[^\\\]+)(?:\\\))?(?&amp;lt;SignOffUsername&amp;gt;[^\]]+)[^\[]+\[\"(?&amp;lt;SignOffComment&amp;gt;[^\:]+)\:\s+(?&amp;lt;SignOffPrivilege&amp;gt;[^\"]+)&amp;lt;/pre&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jan 2025 08:46:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Howto-escape-double-quote-in-regex-when-using-rex/m-p/709214#M239690</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2025-01-20T08:46:13Z</dc:date>
    </item>
    <item>
      <title>Re: Howto escape double quote in regex when using rex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Howto-escape-double-quote-in-regex-when-using-rex/m-p/709215#M239691</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;.&amp;nbsp;I am aware that I need to escape stuff, problem is I do not see where I might have missed one, I already escaped a lot, at least what was required on regex101.&lt;/P&gt;&lt;P&gt;It seems your solution works, will continue with that. Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jan 2025 08:49:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Howto-escape-double-quote-in-regex-when-using-rex/m-p/709215#M239691</guid>
      <dc:creator>jmartens</dc:creator>
      <dc:date>2025-01-20T08:49:32Z</dc:date>
    </item>
    <item>
      <title>Re: Howto escape double quote in regex when using rex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Howto-escape-double-quote-in-regex-when-using-rex/m-p/709217#M239692</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/138072"&gt;@jmartens&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;good for you, see next time!&lt;/P&gt;&lt;P&gt;Ciao and happy splunking&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;&lt;P&gt;P.S.: Karma Points are appreciated &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jan 2025 08:51:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Howto-escape-double-quote-in-regex-when-using-rex/m-p/709217#M239692</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2025-01-20T08:51:29Z</dc:date>
    </item>
  </channel>
</rss>

