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

Re.Posix does not implement character class expressions? #213

Open
lindig opened this issue Aug 26, 2022 · 4 comments
Open

Re.Posix does not implement character class expressions? #213

lindig opened this issue Aug 26, 2022 · 4 comments

Comments

@lindig
Copy link
Contributor

lindig commented Aug 26, 2022

No description provided.

@lindig
Copy link
Contributor Author

lindig commented Aug 26, 2022

utop # let re = Re.Posix.compile_pat {|a[:space:]b|};;
top # Re.exec re "a b" |> Re.Group.all;;
Exception: Not_found.
utop # Re.exec re "a:b" |> Re.Group.all;;
- : string array = [|"a:b"|]

It appears that RE.Posix does not implement character class expressions like [:space:] which are part of the language the interface refers to as documentation:

Unless this is a misunderstanding, I would prefer a more explicit documentation what language is implemented or a a clear warning upfront about the exceptions. Since there is no warning when character class expressions are used, this may come as a surprise.

@lindig lindig changed the title Implementat Re.Posix does not implement character class expressions? Aug 26, 2022
@bcc32
Copy link
Contributor

bcc32 commented Aug 26, 2022

I think you need:

[[:space:]]

instead of just:

[:space:]

Character class expressions are meant to be used inside bracket expressions.

@lindig
Copy link
Contributor Author

lindig commented Aug 26, 2022

Thank you! That makes a lot of sense - so it is a misunderstanding on my part - will test it:

utop # let re = Re.Posix.compile_pat {|a[[:space:]]b|};;
Exception: Re__Posix.Not_supported.

This is re 1.10.4. An explicit error is an improvement but is still looks like this is not implemented.

@bcc32
Copy link
Contributor

bcc32 commented Aug 26, 2022

Ah, indeed, that does not appear to be implemented. It is, however, available in Re.Perl and Re.Pcre. The code could probably be shared between them, since I think they use the same character class names.

I see the following code in posix.ml, ha:

      else if accept ':' then begin
        raise Not_supported (*XXX*)

I suppose that's basically a "TODO"?

rgrinberg added a commit that referenced this issue Apr 14, 2024
Re.Posix doesn't support character class

Signed-off-by: Rudi Grinberg <me@rgrinberg.com>

<!-- ps-id: e4ad97fe-6d31-411e-8a88-d1035a11592d -->
rgrinberg added a commit that referenced this issue Apr 14, 2024
Re.Posix doesn't support character class

Signed-off-by: Rudi Grinberg <me@rgrinberg.com>

<!-- ps-id: e4ad97fe-6d31-411e-8a88-d1035a11592d -->
rgrinberg added a commit that referenced this issue Apr 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants