Skip to content

Expose nqp::findcclass and nqp::notfindclass functionality #146

@lizmat

Description

@lizmat

NQP provides some very powerful primitives for searching strings for characters (not) matching certain Unicode character classes (see https://github.com/perl6/nqp/blob/master/docs/ops.markdown#findcclass and the CCLASS_xxx constants at https://github.com/perl6/nqp/blob/master/docs/ops.markdown#const .

I propose to expose this functionality by adding a two sets of enums corresponding to the CCLASS_xxx constants, and candidates of index and rindex that take those enums as the needle parameter. This would allow you to search for any non-alphabetic character in a string like this:

say "foo5bar".index(NotAlphabeticChar);    # 3
say "foo5bar".index(NotAlphanumericChar);  # Nil

A proof-of-concept implementation can be found in this PR: rakudo/rakudo#3409

Metadata

Metadata

Assignees

Labels

languageChanges to the Raku Programming Language

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions