pomsky icon indicating copy to clipboard operation
pomsky copied to clipboard

New regex flavor targeting Python's `regex` module

Open Aloso opened this issue 2 years ago • 0 comments

Is your feature request related to a problem? Please describe.

The re module, which is part of Python's standard library, has shockingly poor Unicode support.

The biggest issue is that \w and \b don't conform to the Unicode spec, so we can't support them with Unicode enabled. This means that Pomsky is much less useful when targeting Python.

The other problem is that people who use the much better regex module, can't profit from its good Unicode support when using Pomsky.

Describe the solution you'd like

The Python flavor is split in two:

  • PythonRe, the old library from the standard library with poor Unicode support
  • PythonRegex, the better third-party library with good Unicode support

In the CLI, -f python should alias to python-re, but issue a warning.

In the PythonRegex flavor, many other things also work that aren't supported in PythonRe:

  • Unicode properties
  • Grapheme matcher
  • Atomic groups
  • Character set intersection and subtraction

Describe alternatives you've considered

Add a nonstandard_unicode mode, so \w can be used in flavors where \w matches some non-ASCII word characters, but not all (i.e. Python and .NET). This solves the first problem, but not the second.

Aloso avatar Mar 28 '23 12:03 Aloso