<?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 Regex Search: How can I make sure that the next character is not a backslash? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Regex-Search-How-can-I-make-sure-that-the-next-character-is-not/m-p/652907#M225619</link>
    <description>&lt;P&gt;I am trying to dig through some records and trying to get the q (query) from the raw data, but I keep getting data back that includes a backslash after the requested field (mostly as a unicode character representation, /&lt;SPAN&gt;u0026 which is an &amp;amp;).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;For example, I have this search query to capture the page from which a search is being made (i.e., "location"):&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;index="xxxx-data" | regex query="location=([a-zA-Z0-9_]+)+[^&amp;amp;]+" | rex field=_raw "location=(?&amp;lt;location&amp;gt;[a-zA-Z0-9%-]+).*" | rex field=_raw "q=(?&amp;lt;q&amp;gt;[a-zA-Z0-9%-_&amp;amp;+/]+).*"| table location,q&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which mostly works viewing the Statistics tab, except that it occasionally returns the next URL parameter, i.e.,&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="19.884169884169882%" height="25px"&gt;&lt;STRONG&gt;location&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="80.11583011583012%" height="25px"&gt;&lt;STRONG&gt;q&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="19.884169884169882%" height="25px"&gt;home_page&amp;nbsp;&lt;/TD&gt;&lt;TD width="80.11583011583012%" height="25px"&gt;&amp;nbsp;hello+world&amp;nbsp; &amp;nbsp;// this is ok&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="19.884169884169882%" height="47px"&gt;about_page&lt;/TD&gt;&lt;TD width="80.11583011583012%" height="47px"&gt;goodbye+cruel+world\u0026anotherparam=anotherval&amp;nbsp; &amp;nbsp; // not ok&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;The second result should just be &lt;STRONG&gt;goodbye+cruel+world&lt;/STRONG&gt; without the following parameter.&lt;/P&gt;&lt;P&gt;I have tried adding variations on regex NOT [^\\] for a backslash character but everything I've tried has either resulted in an error of the final bracket being escaped, or the backslash character ignored like so:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;rex field=_raw&lt;/STRONG&gt;&amp;nbsp; ...&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="39.575289575289574%"&gt;&lt;STRONG&gt;regex attempt&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="60.424710424710426%"&gt;&lt;STRONG&gt;result&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="39.575289575289574%"&gt;"q=(?&amp;lt;q&amp;gt;[a-zA-Z0-9%-_&amp;amp;+/]+[^\\\]).*"&amp;nbsp;&lt;/TD&gt;&lt;TD width="60.424710424710426%"&gt;goodbye+cruel+world\u0026param=val&amp;nbsp;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="39.575289575289574%"&gt;"q=(?&amp;lt;q&amp;gt;[a-zA-Z0-9%-_&amp;amp;+/]+[^\\]).*"&amp;nbsp;&lt;/TD&gt;&lt;TD width="60.424710424710426%"&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;Error in 'rex' command: Encountered the following error while compiling the regex 'q=(?&amp;lt;q&amp;gt;[a-zA-Z0-9%-_&amp;amp;+/]+[^\]).*': Regex: missing terminating ] for character class.&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="39.575289575289574%"&gt;"q=(?&amp;lt;q&amp;gt;[a-zA-Z0-9%-_&amp;amp;+/]+[^\]).*"&amp;nbsp;&lt;/TD&gt;&lt;TD width="60.424710424710426%"&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;Error in 'rex' command: Encountered the following error while compiling the regex 'q=(?&amp;lt;q&amp;gt;[a-zA-Z0-9%-_&amp;amp;+/]+[^\]).*': Regex: missing terminating ] for character class.&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="39.575289575289574%"&gt;"q=(?&amp;lt;q&amp;gt;[a-zA-Z0-9%-_&amp;amp;+/]+[^\\u0026]).*"&lt;/TD&gt;&lt;TD width="60.424710424710426%"&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;Error in 'rex' command: Encountered the following error while compiling the regex 'q=(?&amp;lt;q&amp;gt;[a-zA-Z0-9%-_&amp;amp;+/]+[^\u0026]).*': Regex: PCRE does not support \L, \l, \N{name}, \U, or \u.&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="39.575289575289574%"&gt;"q=(?&amp;lt;q&amp;gt;[a-zA-Z0-9%-_&amp;amp;+/]+[^u0026]).*"&lt;/TD&gt;&lt;TD width="60.424710424710426%"&gt;&amp;nbsp;goodbye+cruel+world\u0026param=val&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;"&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="39.575289575289574%"&gt;"q=(?&amp;lt;q&amp;gt;[a-zA-Z0-9%-_&amp;amp;+/]+[^&amp;amp;]).*"&lt;/TD&gt;&lt;TD width="60.424710424710426%"&gt;&amp;nbsp;goodbye+cruel+world\u0026param=val&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;"&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;"q=(?&amp;lt;q&amp;gt;[a-zA-Z0-9%-_&amp;amp;+/]+).*"&lt;/TD&gt;&lt;TD&gt;goodbye+cruel+world\u0026param=val&amp;nbsp;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;"q=(?&amp;lt;q&amp;gt;[a-zA-Z0-9%-_&amp;amp;+/^\\\\]+)"&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;goodbye+cruel+world\u0026param=val&amp;nbsp;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Events tab data is like:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Event

apple: honeycrisp
ball: baseball
car: Ferrari
query: param1=val1&amp;amp;param2=val2&amp;amp;param3=val3&amp;amp;q=goodbye+cruel+world&amp;amp;param=val
status: 200&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;... etc ...&lt;/P&gt;&lt;P&gt;SO, how can I get the &lt;STRONG&gt;q&lt;/STRONG&gt; value to return just the first parameter, ignoring anything that has a &lt;STRONG&gt;\&lt;/STRONG&gt; or &lt;STRONG&gt;&amp;amp;&lt;/STRONG&gt; before it and terminating just at &lt;STRONG&gt;q&lt;/STRONG&gt;?&lt;/P&gt;&lt;P&gt;And please, if you would be so kind, include an explanation of why what you suggest works?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Wed, 02 Aug 2023 15:08:20 GMT</pubDate>
    <dc:creator>isxtn</dc:creator>
    <dc:date>2023-08-02T15:08:20Z</dc:date>
    <item>
      <title>Regex Search: How can I make sure that the next character is not a backslash?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Search-How-can-I-make-sure-that-the-next-character-is-not/m-p/652907#M225619</link>
      <description>&lt;P&gt;I am trying to dig through some records and trying to get the q (query) from the raw data, but I keep getting data back that includes a backslash after the requested field (mostly as a unicode character representation, /&lt;SPAN&gt;u0026 which is an &amp;amp;).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;For example, I have this search query to capture the page from which a search is being made (i.e., "location"):&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;index="xxxx-data" | regex query="location=([a-zA-Z0-9_]+)+[^&amp;amp;]+" | rex field=_raw "location=(?&amp;lt;location&amp;gt;[a-zA-Z0-9%-]+).*" | rex field=_raw "q=(?&amp;lt;q&amp;gt;[a-zA-Z0-9%-_&amp;amp;+/]+).*"| table location,q&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which mostly works viewing the Statistics tab, except that it occasionally returns the next URL parameter, i.e.,&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="19.884169884169882%" height="25px"&gt;&lt;STRONG&gt;location&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="80.11583011583012%" height="25px"&gt;&lt;STRONG&gt;q&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="19.884169884169882%" height="25px"&gt;home_page&amp;nbsp;&lt;/TD&gt;&lt;TD width="80.11583011583012%" height="25px"&gt;&amp;nbsp;hello+world&amp;nbsp; &amp;nbsp;// this is ok&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="19.884169884169882%" height="47px"&gt;about_page&lt;/TD&gt;&lt;TD width="80.11583011583012%" height="47px"&gt;goodbye+cruel+world\u0026anotherparam=anotherval&amp;nbsp; &amp;nbsp; // not ok&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;The second result should just be &lt;STRONG&gt;goodbye+cruel+world&lt;/STRONG&gt; without the following parameter.&lt;/P&gt;&lt;P&gt;I have tried adding variations on regex NOT [^\\] for a backslash character but everything I've tried has either resulted in an error of the final bracket being escaped, or the backslash character ignored like so:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;rex field=_raw&lt;/STRONG&gt;&amp;nbsp; ...&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="39.575289575289574%"&gt;&lt;STRONG&gt;regex attempt&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD width="60.424710424710426%"&gt;&lt;STRONG&gt;result&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="39.575289575289574%"&gt;"q=(?&amp;lt;q&amp;gt;[a-zA-Z0-9%-_&amp;amp;+/]+[^\\\]).*"&amp;nbsp;&lt;/TD&gt;&lt;TD width="60.424710424710426%"&gt;goodbye+cruel+world\u0026param=val&amp;nbsp;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="39.575289575289574%"&gt;"q=(?&amp;lt;q&amp;gt;[a-zA-Z0-9%-_&amp;amp;+/]+[^\\]).*"&amp;nbsp;&lt;/TD&gt;&lt;TD width="60.424710424710426%"&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;Error in 'rex' command: Encountered the following error while compiling the regex 'q=(?&amp;lt;q&amp;gt;[a-zA-Z0-9%-_&amp;amp;+/]+[^\]).*': Regex: missing terminating ] for character class.&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="39.575289575289574%"&gt;"q=(?&amp;lt;q&amp;gt;[a-zA-Z0-9%-_&amp;amp;+/]+[^\]).*"&amp;nbsp;&lt;/TD&gt;&lt;TD width="60.424710424710426%"&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;Error in 'rex' command: Encountered the following error while compiling the regex 'q=(?&amp;lt;q&amp;gt;[a-zA-Z0-9%-_&amp;amp;+/]+[^\]).*': Regex: missing terminating ] for character class.&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="39.575289575289574%"&gt;"q=(?&amp;lt;q&amp;gt;[a-zA-Z0-9%-_&amp;amp;+/]+[^\\u0026]).*"&lt;/TD&gt;&lt;TD width="60.424710424710426%"&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;Error in 'rex' command: Encountered the following error while compiling the regex 'q=(?&amp;lt;q&amp;gt;[a-zA-Z0-9%-_&amp;amp;+/]+[^\u0026]).*': Regex: PCRE does not support \L, \l, \N{name}, \U, or \u.&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="39.575289575289574%"&gt;"q=(?&amp;lt;q&amp;gt;[a-zA-Z0-9%-_&amp;amp;+/]+[^u0026]).*"&lt;/TD&gt;&lt;TD width="60.424710424710426%"&gt;&amp;nbsp;goodbye+cruel+world\u0026param=val&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;"&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="39.575289575289574%"&gt;"q=(?&amp;lt;q&amp;gt;[a-zA-Z0-9%-_&amp;amp;+/]+[^&amp;amp;]).*"&lt;/TD&gt;&lt;TD width="60.424710424710426%"&gt;&amp;nbsp;goodbye+cruel+world\u0026param=val&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;"&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;"q=(?&amp;lt;q&amp;gt;[a-zA-Z0-9%-_&amp;amp;+/]+).*"&lt;/TD&gt;&lt;TD&gt;goodbye+cruel+world\u0026param=val&amp;nbsp;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;"q=(?&amp;lt;q&amp;gt;[a-zA-Z0-9%-_&amp;amp;+/^\\\\]+)"&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;goodbye+cruel+world\u0026param=val&amp;nbsp;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Events tab data is like:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Event

apple: honeycrisp
ball: baseball
car: Ferrari
query: param1=val1&amp;amp;param2=val2&amp;amp;param3=val3&amp;amp;q=goodbye+cruel+world&amp;amp;param=val
status: 200&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;... etc ...&lt;/P&gt;&lt;P&gt;SO, how can I get the &lt;STRONG&gt;q&lt;/STRONG&gt; value to return just the first parameter, ignoring anything that has a &lt;STRONG&gt;\&lt;/STRONG&gt; or &lt;STRONG&gt;&amp;amp;&lt;/STRONG&gt; before it and terminating just at &lt;STRONG&gt;q&lt;/STRONG&gt;?&lt;/P&gt;&lt;P&gt;And please, if you would be so kind, include an explanation of why what you suggest works?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 02 Aug 2023 15:08:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Search-How-can-I-make-sure-that-the-next-character-is-not/m-p/652907#M225619</guid>
      <dc:creator>isxtn</dc:creator>
      <dc:date>2023-08-02T15:08:20Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Search: How can I make sure that the next character is not a backslash?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Search-How-can-I-make-sure-that-the-next-character-is-not/m-p/652913#M225622</link>
      <description>&lt;P&gt;Not entirely sure whether your _raw field includes an &amp;amp; or \u0026, anyway for backslashes you have to escape the escape&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex "q=(?&amp;lt;q&amp;gt;[^\\\\]+)"&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 02 Aug 2023 14:55:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Search-How-can-I-make-sure-that-the-next-character-is-not/m-p/652913#M225622</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-08-02T14:55:14Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Search: How can I make sure that the next character is not a backslash?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Search-How-can-I-make-sure-that-the-next-character-is-not/m-p/652915#M225624</link>
      <description>&lt;P&gt;Thank you. The raw data is an actual "&amp;amp;" not the unicode.&amp;nbsp; Even when I take out the "&amp;amp;" from the regex I still get the unicode reply.&amp;nbsp;&lt;/P&gt;&lt;P&gt;And when I changed the regex to&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;rex field=_raw "q=(?&amp;lt;q&amp;gt;[a-zA-Z0-9%-_&amp;amp;+/^\\\\]+)"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I still get the&lt;STRONG&gt; \u0026param=val&lt;/STRONG&gt; ...&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there another pattern I should use?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Aug 2023 15:11:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Search-How-can-I-make-sure-that-the-next-character-is-not/m-p/652915#M225624</guid>
      <dc:creator>isxtn</dc:creator>
      <dc:date>2023-08-02T15:11:33Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Search: How can I make sure that the next character is not a backslash?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Search-How-can-I-make-sure-that-the-next-character-is-not/m-p/652919#M225625</link>
      <description>&lt;LI-CODE lang="markup"&gt;| rex "q=(?&amp;lt;q&amp;gt;[^&amp;amp;]+)"&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 02 Aug 2023 15:41:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Search-How-can-I-make-sure-that-the-next-character-is-not/m-p/652919#M225625</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-08-02T15:41:39Z</dc:date>
    </item>
  </channel>
</rss>

