Вот модуль, о котором я спрашиваю: https://pypi.org/project/regex/, это regex Мэтью Барнетта.
На странице описания проекта разница в поведении между V0 и V1 указана как (обратите внимание на то, что выделено жирным шрифтом):
Old vs new behaviour
In order to be compatible with the
remodule, this module has 2 behaviours:
Version 0 behaviour (old behaviour, compatible with the re module):
Please note that the re module’s behaviour may change over time, and I’ll endeavour to match that behaviour in version 0.
- Indicated by the
VERSION0orV0flag, or(?V0)in the pattern.- Case-insensitive matches in Unicode use simple case-folding by default.
Version 1 behaviour (new behaviour, possibly different from the re module):
- Indicated by the
VERSION1orV1flag, or(?V1)in the pattern.- Case-insensitive matches in Unicode use full case-folding by default.
If no version is specified, the regex module will default to
regex.DEFAULT_VERSION.
Я попробовал несколько примеров сам, но не понял, что он делает:
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import regex
>>> r = regex.compile("(?V0i)и")
>>> r
regex.Regex('(?V0i)и', flags=regex.I | regex.V0)
>>> r.search("И")
<regex.Match object; span=(0, 1), match='И'>
>>> regex.search("(?V0i)é", "É")
<regex.Match object; span=(0, 1), match='É'>
>>> regex.search("(?V0i)é", "E")
>>> regex.search("(?V1i)é", "E")
В чем разница между простым складыванием корпуса и полным складыванием корпуса? Или вы можете привести пример, где регулярное выражение (без учета регистра) соответствует чему-то в V1, но не соответствует V0?
@MichaelButscher Отлично, это работает. Вы можете получить зеленую галочку, если напишете это как ответ.






Он следует за Складной столик в Юникоде. Выдержка:
# The entries in this file are in the following machine-readable format:
#
# <code>; <status>; <mapping>; # <name>
#
# The status field is:
# C: common case folding, common mappings shared by both simple and full mappings.
# F: full case folding, mappings that cause strings to grow in length. Multiple characters are separated by spaces.
# S: simple case folding, mappings to single characters where different from F.
[...]
# Usage:
# A. To do a simple case folding, use the mappings with status C + S.
# B. To do a full case folding, use the mappings with status C + F.
Складывание отличается только для нескольких специальных символов, например, для маленьких и заглавных латинских диезов:
00DF; F; 0073 0073; # LATIN SMALL LETTER SHARP S
[...]
1E9E; F; 0073 0073; # LATIN CAPITAL LETTER SHARP S
1E9E; S; 00DF; # LATIN CAPITAL LETTER SHARP S
Не проверено, но, вероятно, следует за этот стол. Полная сворачивание регистра может заменить несколько специальных символов двумя символами, а простое сворачивание — нет. Такие персонажи, например. заглавная и строчная латинская диез s.