GeezerVison is showing github.com — `re` should support `\p{...}` character properties · Issue #95555 · python/cpython
re should support \p{...} character properties #95555
DescriptionFeature or enhancement
Reproduced steps
re.compile('\p{script=Han}') #
actual:
will throw error
expect:
pass
Info:
changed log
8/3 add more info . Final thx @JelleZijlstra give an helpful link
Linked PRs
Reacted by Kohányi Róbert ActivityJelleZijlstra commented on Aug 2, 2022 Could you clarify why you think this should work? As far as I can tell \p has no special meaning in regex. ronaldoussoren commented on Aug 2, 2022 Reacted by 朧月 and Oleg Iarygin mrabarnett commented on Aug 2, 2022 Reacted by 朧月, Lijd and Martin Zaťko changed the title [-]re: 應該支援漢字正則表達式 \p{Han}[/-] [+]re: should support Chinese character regular expression \p{Han}[/+] on Aug 3, 2022corona10 commented on Aug 3, 2022 @LonYui
re: 應該支援漢字正則表達式 \p{Han}
Please write the issue title in English if possible, some of the core devs are not familiar with Chinese.
(Same reason why I do not write issue titles in Korean.)
For reducing the cost of understanding your suggestion, I re-wrote the issue title in English. Reacted by 朧月 and Daniël van Noord arhadthedev commented on Mar 4, 2023 Removing the pending label because @ronaldoussoren explained what the OP means. changed the title [-]re: should support Chinese character regular expression \p{Han}[/-] [+]`re` should support `\p{...}` character properties[/+] on Mar 4, 2023arhadthedev commented on Mar 4, 2023 Note: currently re supports only \number, \a, \b, \f, \n, \N, \r, \t, \u, \U, \v, \x, and \\. ncoghlan commented on Jun 24, 2025 As a concrete example where this limitation can cause problems: while JSON Schema formally only supports a limited number of escape sequences, in practice schemas may end up containing patterns that use any of the defined JavaScript regex character classes.
Python supports most of the same character classes, but \p/\P is a notable omission. Whether or not that can reasonably be worked around by using regex instead of re depends on how the affected regex is being processed (if it's in a third party library, it may not be straightforward to get it to use a different regex engine) added 4 commits that reference this issue on Jun 23, 2026pythongh-95555: Add Regional_Indicator, Hex_Digit and ASCII_Hex_Digit… gh-95555: Support Unicode property escapes \p{...} in regular express…
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|