jed-users mailing list

[2021 Date Index] [2021 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: [jed-users] pcre_matches - shouldn't PCRE_DOTALL match newlines?


Hi Morten,

Morten Bo Johansen <mbj@xxxxxxxxx> wrote:
> Hi
>
> If I have a multiline string, str = "abc\nabc", and do
>
>   str = pcre_matches(".*", str; PCRE_DOTALL);
>   
> I would expect "str[0]" to be the same "abc\nabc", but I only
> get "abc".

You discovered a bug in pcre.sl.  Here is a patch:

diff --git a/modules/pcre.sl b/modules/pcre.sl
index fc062f4..b9ef467 100644
--- a/modules/pcre.sl
+++ b/modules/pcre.sl
@@ -25,7 +25,7 @@ Qualifiers:\n\
    if (typeof (re) != PCRE_Type)
      {
        variable compile_options = qualifier ("options", 0);
-       re = pcre_compile (re, options);
+       re = pcre_compile (re, compile_options);
      }

Also note that the calling syntax you want is:

  str = pcre_matches(".*", str; options=PCRE_DOTALL);

Thanks,
--John

>
> This also happens without PCRE_DOTALL, so it doesn't seem to
> have any effect. Is my syntax wrong?
>
> How do I match all characters in a whole string across lines
> with pcre_matches()?
>
> Thanks,
> Morten
> _______________________________________________
> For list information, visit <http://jedsoft.org/jed/mailinglists.html>.
>
_______________________________________________
For list information, visit <http://jedsoft.org/jed/mailinglists.html>.


[2021 date index] [2021 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]