pcre2


Vocabulary
pcre2

Class description
A compiled regular expression. Instances are disposable; release them with dispose or with-disposal.

Definition


Methods




M:: pcre2 findall ( subject obj -- matches )
[
subject utf8 encode
:> subject_bytes subject_bytes length :> subject_length
obj handle>> :> re re pcre2-utf? :> utf? re pcre2-crlf?
:> crlf? re f pcre2_match_data_create_from_pattern
&pcre2_match_data_free :> match_data 0 :> start_offset!
0 :> options! re subject_bytes subject_length
start_offset options match_data f pcre2_match
:> rc re pcre2-name-table-entries :> name_table rc 0 < [
rc
{ { PCRE2_ERROR_NOMATCH [ ~array~ ] } [ throw ] }
case
] [
rc assert-positive drop
match_data pcre2_get_ovector_pointer match_data
pcre2_get_ovector_count 2 *
PCRE2_SIZE <c-direct-array> :> ovector [
rc ovector name_table subject_bytes
subject_length parse-match , [
f :> break?! 0 options! ovector second
start_offset! ovector first2 = [
ovector first subject_length =
2147483656 options!
] [
match_data pcre2_get_startchar
:> startchar start_offset startchar <=
~quotation~ ~quotation~ if
] if
[ f ] [
re subject_bytes subject_length
start_offset options match_data f
pcre2_match
:> rc rc PCRE2_ERROR_NOMATCH =
~quotation~ ~quotation~ if
] if
] loop
] { } make
] if
] with-destructors ;