Substring scan assertion with pcre2test fails

27 views
Skip to first unread message

David Wahlstedt

unread,
Oct 3, 2024, 6:22:09 PM10/3/24
to PCRE2 discussion list
Hello,

I tried the example of substring scan assertion:

\b(\w++)(*scs:(1).+rh)

from the pcre2pattern man page.
In both pcre2test 10.39 and 10.45 I get:

PCRE2 version 10.45-DEV 2024-06-09 (8-bit)
/\b(\w++)(*scs:(1).+rh)/debug
Failed: error 195 at offset 13: (*alpha_assertion) not recognized
arhg

What am I doing wrong? I haven't turned on dfa_match as far as I know.
Is my version of pcre2 too old? (v10.45 9 june)

BTW, questions about substring scan assertions: is it like groups: option settings that appear inside it last only until its end? Is the scan assertion quantifiable?

BR,
David

Philip Hazel

unread,
Oct 4, 2024, 4:41:37 AM10/4/24
to David Wahlstedt, PCRE2 discussion list
Too old. The substring scan facility was merged into the Git repo on 30th August.
Regards,
Philip


--
You received this message because you are subscribed to the Google Groups "PCRE2 discussion list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pcre2-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pcre2-dev/139c476b-f274-42d6-9133-76c4d95fa63en%40googlegroups.com.

David Wahlstedt

unread,
Oct 4, 2024, 5:46:26 AM10/4/24
to PCRE2 discussion list
Thanks, now it works!

When I try an empty group list it complains about "reference to non-existent supattern".
So I guess the group list has to be non-empty?
Of course it's weird to use this construction with an empty group list, but from a syntax rule point of view it is good to know.

PCRE2 version 10.45-DEV 2024-06-09 (8-bit)
/a(*scs:())/debug
Failed: error 115 at offset 8: reference to non-existent subpattern
a

The version string above still says 2024-06-09, but it is actually from git today, and it ran the \b(\w++)(*scs:(1).+rh) example successfully.

Regards,
David

Zoltan Herczeg

unread,
Oct 4, 2024, 11:23:34 AM10/4/24
to David Wahlstedt, PCRE2 discussion list
Hi,

yes, the list must not be empty. The error message could be improved.

Regards,
Zoltan
> To view this discussion on the web visit https://groups.google.com/d/msgid/pcre2-dev/ecafcc63-cb3d-46c5-ba9d-62e05e70f315n%40googlegroups.com.

Zoltan Herczeg

unread,
Oct 4, 2024, 11:30:24 AM10/4/24
to David Wahlstedt, PCRE2 discussion list
Hi,

scan substing is a completely new feature which will be available in
the next release. You can try it if you compile pcre2 from the github
repository. I hope you will like it!

Scan substring is an assertion, it should behave like any other
assertions such as (?=...) . That means it matches to an empty string,
(*ACCEPT) accepts it, etc. Regardless, you can add quantifiers, a {6}
will repeat it 6 times. The ? can also be useful, but * is practically
a ?. Local options are limited to brackets. For example, in the
/()(*scs:(1).(?s).)./ pattern, only the second dot matches to all
characters (including newline).

Regards,
Zoltan
Reply all
Reply to author
Forward
0 new messages