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

Supporting (more) pcre2 options #30

Open
rkallos opened this issue Jun 2, 2021 · 2 comments
Open

Supporting (more) pcre2 options #30

rkallos opened this issue Jun 2, 2021 · 2 comments

Comments

@rkallos
Copy link

rkallos commented Jun 2, 2021

I've found myself in the position where I've hacked a local copy of this library to support the PCRE2_MULTILINE option. I think it might be nice to let users pick and choose options when compiling patterns, but I'm not sure about the best way to do that.

  • Creating primitives and using collections.Flags might be one way, but that would necessitate passing another argument to Regex.create(), which raises the issue of positioning the argument. flags before jit breaks compatibility with existing code. flags after jit means that any user who wants to set flags would have to also choose whether or not to jit-compile the pattern, adding boilerplate.
  • Another option might be to absorb the jit argument into a Flags object, but that would also break compatibility.
  • One way to not break compatibility or add boilerplate might be to expose fun ref pattern_options() ?, but that method would have to recompile the pattern, which is a bit of a waste.
  • Exposing something like new with_opts(from: ByteSeq box, jit: Bool = true, flags: PCRE2Flags = ...) seems like a good option. It's my favorite at the moment.

I'm open to other ideas, and I'd be glad to contribute this enhancement once I have a better idea of what we want for this library.

@ergl
Copy link
Member

ergl commented Jun 2, 2021

Since the jit argument has a default value (true), putting the flags argument after jit, and giving a default value, would be my preferred option. Users who only want to change the flag, but not the jit can do Regex.create(string where flags = ...)

@rkallos
Copy link
Author

rkallos commented Jun 2, 2021

Fabulous! I totally forgot about where. That seems like it would work :)

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