Skip to content

Supporting (more) pcre2 options #30

@rkallos

Description

@rkallos

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions