GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-152100: Support set operations in character classes by serhiy-storchaka · Pull Request #152153 · python/cpython

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Jun 25, 2026 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Implement UTS #18 RL1.3 set operations in regular expression character classes: difference [A--B], intersection [A&&B] and union [A||B], with nested, complemented and compound operands and arbitrary left-to-right chaining ([a-z--[aeiou]&&\w]). Symmetric difference [A~~B] remains reserved (still a FutureWarning).

These tokens (--, &&, ||, and nested [) have been reserved since 3.7 via FutureWarning, so this turns the warnings into real syntax.

The feature is parser-only: each operation maps to an assertion on the matched character — [A--B] → A(?<![B]), [A&&B] → A(?<=[B]), [A||B] → a merged charset [AB] or an alternation — so no charset complement is ever formed and the result is correct under IGNORECASE. A leading ^ negates by De Morgan, pushing the negation into the operands. The engine and MAGIC are untouched.

A [ opens a nested set only immediately after a set operator; at the start of a class it stays an ordinary literal, so existing patterns such as [[:alpha:]] and glob's [*?[] keep their meaning.

The new syntax is also used in the standard library (_strptime, textwrap, doctest, pkgutil).

🤖 Generated with Claude Code

  • Issue: Support set operations in regular expression character classes #152100

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@serhiy-storchaka @claude
pythongh-152100: Support set operations in character classes
f9a4807
Implement set difference [A--B], intersection [A&&B] and union [A||B] in
regular expression character classes (Unicode Technical Standard #18),
including nested, complemented and compound set operands.  Symmetric
difference [A~~B] remains reserved.

Also use the new syntax in the standard library (_strptime, textwrap,
doctest, pkgutil).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@serhiy-storchaka
serhiy-storchaka requested review from AA-Turner, FFY00, StanFromIreland, ericsnowcurrently and pganssle as code owners June 25, 2026 06:19
@bedevere-app bedevere-app Bot added the awaiting core review label Jun 25, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Jun 25, 2026
Support set operations in regular expression character classes #152100
Open
@read-the-docs-community

read-the-docs-community Bot commented Jun 25, 2026

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #33302005 | 📁 Comparing f9a4807 against main (3db3bba)

  🔍 Preview build  

3 files changed
± library/re.html
± whatsnew/3.16.html
± whatsnew/changelog.html
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@serhiy-storchaka
serhiy-storchaka merged commit bd4bd3e into python:main Jun 25, 2026
56 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting core review label Jun 25, 2026
@serhiy-storchaka
serhiy-storchaka deleted the re-set-ops-stage1 branch June 25, 2026 07:09
@eendebakpt eendebakpt mentioned this pull request Nov 1, 2026
Regression in re.compile() performance #161125
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@pganssle pganssle Awaiting requested review from pganssle pganssle is a code owner
@StanFromIreland StanFromIreland Awaiting requested review from StanFromIreland StanFromIreland is a code owner
@ericsnowcurrently ericsnowcurrently Awaiting requested review from ericsnowcurrently ericsnowcurrently is a code owner
@FFY00 FFY00 Awaiting requested review from FFY00 FFY00 is a code owner
@AA-Turner AA-Turner Awaiting requested review from AA-Turner AA-Turner is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@serhiy-storchaka
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.