Failure with comment in editor when commenting out a regex

Wednesday, 1 August 2018 · 5 messages · last reply 2 Aug 2018
AM
Andreas Mixich1 Aug 2018 22:31 #
Hi, it may be already known, that the editor seems to hick up with the parsing, when it comes around some strange combinations of chars within the comment. I just came around this:
  (: let $str := "http://foo.bar/barz/index.html?bla=2"
  let $str2 := "http://www.ics.uci.edu/pub/ietf/uri/#Related"
  let $str3 := "http://192.168.2.1/index.html?bla=2"
  let $scheme := substring-before($str, ':')

  let $host :=
analyze-string($str3,"^(([^:/?#]+):)(//([^/?#]*))([^?#]*)(\?([^#]*))(#(.*))?")
  return $host :)
Editor/GUI warns, that: "no expression allowed in library module" and places error marker at the two slashes // after the :)( in the regex.
-- Goody Bye, Minden jót, Mit freundlichen Grüßen, Andreas Mixich
CG
Christian Grün1 Aug 2018 22:48 #
Quoted text · Andreas Mixich · 2 lines
> Editor/GUI warns, that: "no expression allowed in library module" and > places error marker at the two slashes // after the :)( in the regex.
I’m being presented with the following error message: [XPST0003] Invalid value, simple expression expected. The error message is correct, because your comment already ends at line 7, column 37: .... ?#]+):) Please note that characters within a comment will never be parsed, as a shorter (invalid) query may demonstrate: (: ':)' :) 123 I’m not sure how you got this "no expression allowed in library module" error message. Could you possibly provide us a step-by-step example?
AM
Andreas Mixich1 Aug 2018 23:42 #
Hi Christian,
Quoted text · Christian Grün · 3 lines
you wrote:> I’m being presented with the following error message: > > [XPST0003] Invalid value, simple expression expected.
Me too, if I just copy and paste the code I have sent. See, attached, a simple module, that produces the error I named first.
Quoted text · Christian Grün · 4 lines
> The error message is correct, because your comment already ends at > line 7, column 37: > > .... ?#]+):)
Aehm, no, that is still part of the regular expression. See the quotes around the regex encapsulating the :) part. If you remove the comment, that code block will execute and produce this result:
  <fn:analyze-string-result
xmlns:fn="http://www.w3.org/2005/xpath-functions">
    <fn:match>
      <fn:group nr="1">
        <fn:group nr="2">http</fn:group>:</fn:group>
      <fn:group nr="3">//<fn:group nr="4">192.168.2.1</fn:group>
      </fn:group>
      <fn:group nr="5">/index.html</fn:group>
      <fn:group nr="6">?<fn:group nr="7">bla=2</fn:group>
      </fn:group>
    </fn:match>
  </fn:analyze-string-result>
Quoted text · Christian Grün · 3 lines
> I’m not sure how you got this "no expression allowed in library > module" error message. Could you possibly provide us a step-by-step > example?
Sure, see attached file. I just re-tested. The file, as is, produces "No expression allowed in library module" If you remove the first line ('module namespace foo = "foo:bar";'), then mark the out-commented code block and hit CTRL-K, it removes the outermost (: :), the block becomes executable and produces mentioned result.
-- Goody Bye, Minden jót, Mit freundlichen Grüßen, Andreas Mixich
LQ
Liam R. E. Quinin reply to Andreas Mixich, 1 Aug 2018, 22:312 Aug 2018 01:07 #
Quoted text · Andreas Mixich · 5 lines
On Wed, 2018-08-01 at 22:31 +0200, Andreas Mixich wrote: > host :) > > Editor/GUI warns, that: "no expression allowed in library module" and > places error marker at the two slashes // after the :)( in the regex.
Well, it's right - since it's in a comment it's not in a regex, it's just :) in a comment. Liam
-- Liam Quin - web slave for https://www.fromoldbooks.org/ with fabulous vintage art and fascinating texts to read.
CG
Christian Grün2 Aug 2018 07:58 #
Quoted text · Liam R. E. Quin · 2 lines
> > Aehm, no, that is still part of the regular expression.
This does not apply anymore if you insert (: before the quotes. As Liam wrote, the regex won’t be parsed anymore in that case.

⚡Generated with XQuery