Support set operations in regular expression character classes
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
Feature or enhancement
Implement the set operations of Unicode Technical Standard #18 RL1.3 in re character classes, together with nested sets.
gh-74534 added FutureWarnings in Python 3.7 for the ambiguous constructs (--, &&, ~~, ||, and a leading [) as preparation for this syntax; this issue turns them into operators.
Two character sets are combined by an operator, where an operand may be a nested set in brackets:
[A--B]— difference: a character inAbut not inB.[A&&B]— intersection: a character in bothAandB.[A||B]— union: a character inAorB.[A~~B]— symmetric difference: a character inAorBbut not both.
Operators have no precedence and apply left to right; nested sets are used to group. A leading ^ complements the whole result.
For example, [a-z--[aeiou]] matches an ASCII lowercase consonant and [\w&&[a-z]] matches an ASCII lowercase letter.
Linked PRs
- gh-152153
- gh-152154
- gh-152214
- gh-153022
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading Python's re character-class handling and Unicode Technical Standard #18 RL1.3. Confirm completion against the listed difference, intersection, union, symmetric-difference, nesting, left-to-right, and complement examples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 25/100