perl -e 'use v5.40; use Inline C => q{ int call_pregexec(SV *regex, SV *sv) { REGEXP *rx= SvRX(regex); STRLEN len; char *buf= SvPV(sv, len); return pregexec(rx, buf, buf+len, buf, 0, sv, 1); } }; say "098mnb" =~ /([0-9])([a-z])/; say call_pregexec(qr/([a-z])([0-9])/, "abc123"); say $&; say $1; say $2; say $+[0]; say $+[1];'