Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
lizmat opened this issue Jan 7, 2020 · 0 comments
Open

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

lizmat opened this issue Jan 7, 2020 · 0 comments
Assignees
Labels

Comments

@lizmat
Copy link
Contributor

@lizmat lizmat commented Jan 7, 2020

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

@lizmat lizmat added the language label Jan 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.