You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using the regex lib to make a port of language tool libs (originally java) for sentence and word tokenization.
Those are relying on \v\h heavily. Some of those rules are shipped in the xml files full of regexes and I'm willing not to alter those to not to maintain a separate copy. I can kind of workaround it by replacing \v with VERTICAL_SPACE: str = "\u000a\u000b\u000c\u000d\u0085\u2028\u2029" but it's another tiny nightmare, as those regexes can come in different fashions: \v*, [\v\t]*, etc.
I can see that code suggest \v pseudo, but I cannot understand why it doesn't work then:
In [3]: import regex as re
In [8]: re.search(r"\v", "\n") is None
Out[8]: True
In [9]: re.search(r"\v", "\n", flags=re.M | re.U | re.V1) is None
Out[9]: True
There are far fewer characters that need to match: [\x0A\x0B\x0C\x0D\x85\u2028\u2029] or [\x0A-x0D\x85\u2028\u2029].
Maybe it could be added as \V, although that would be inconsistent with \h, and there are pairs of lowercase/uppercase escape codes where the uppercase one is the negative of the lowercase one, e.g. \d and \D. On the other hand, those implementations that have \h and \v don't have \H and \V.
Also, I don't want to add something that the re module might do differently if it were added later.
On Tue, Aug 16, 2022 at 5:18 PM mrabarnett ***@***.***> wrote:
There are far fewer characters that need to match:
[\x0A\x0B\x0C\x0D\x85\u2028\u2029] or [\x0A-x0D\x85\u2028\u2029].
Maybe it could be added as \V, although that would be inconsistent with \h,
and there are pairs of lowercase/uppercase escape codes where the uppercase
one is the negative of the lowercase one, e.g. \d and \D. On the other
hand, those implementations that have \h and \v don't have \H and \V.
Also, I don't want to add something that the re module might do
differently if it were added later.
That's why it hasn't been added already.
—
Reply to this email directly, view it on GitHub
<#477 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABAA4WMEYPZUNSUUHPGUF3VZOPMJANCNFSM56TVAIOQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
Now I'm thinking about \y and \Y, which look a little like \v and \V. ProgressSQL uses them instead of \b and \B, which every other implementation that I know of uses, possibly because \b normally represents \x08 outside regex, and does still within characters classes.
I want the regex module to remain compatible with the re module, and just in case they ever get added there in the future, I'm soliciting opinions on python-dev.
I've added \p{HorizSpace} (\p{H}) and \p{VertSpace} (\p{V}) in regex 2022.8.17, which is currently being built on GitHub and should arrive on PyPI soon.
Reacted by Dmytro Chaplynskyi and Wesley J. Landaker
On Tue, Aug 16, 2022 at 11:29 PM mrabarnett ***@***.***> wrote:
Now I'm thinking about \y and \Y, which look a little like \v and \V.
ProgressSQL uses them instead of \b and \B, which every other
implementation that I know of uses, possibly because \b normally
represents \x08 outside regex, and does still within characters classes.
I want the regex module to remain compatible with the re module, and just
in case they ever get added there in the future, I'm soliciting opinions on
python-dev.
—
Reply to this email directly, view it on GitHub
<#477 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABAA4VV4QEAN2LIUDUDSXTVZP2ZNANCNFSM56TVAIOQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
Activity
dchaplinsky commentedon Aug 15, 2022
I can see that code suggest \v pseudo, but I cannot understand why it doesn't work then:
mrabarnett commentedon Aug 16, 2022
\valready exists in Python as being short for\x0b(LINE TABULATION):dchaplinsky commentedon Aug 16, 2022
Thanks for the prompt reply!
Any ideas on the matching of vertical space?
mrabarnett commentedon Aug 16, 2022
There are far fewer characters that need to match:
[\x0A\x0B\x0C\x0D\x85\u2028\u2029]or[\x0A-x0D\x85\u2028\u2029].Maybe it could be added as
\V, although that would be inconsistent with\h, and there are pairs of lowercase/uppercase escape codes where the uppercase one is the negative of the lowercase one, e.g.\dand\D. On the other hand, those implementations that have\hand\vdon't have\Hand\V.Also, I don't want to add something that the re module might do differently if it were added later.
That's why it hasn't been added already.
dchaplinsky commentedon Aug 16, 2022
mrabarnett commentedon Aug 16, 2022
I've come across a mention of
\Hand\V, so using\Vwould be a bad idea.dchaplinsky commentedon Aug 16, 2022
mrabarnett commentedon Aug 16, 2022
Now I'm thinking about
\yand\Y, which look a little like\vand\V. ProgressSQL uses them instead of\band\B, which every other implementation that I know of uses, possibly because\bnormally represents\x08outside regex, and does still within characters classes.I want the regex module to remain compatible with the re module, and just in case they ever get added there in the future, I'm soliciting opinions on python-dev.
mrabarnett commentedon Aug 17, 2022
I've added
\p{HorizSpace}(\p{H}) and\p{VertSpace}(\p{V}) in regex 2022.8.17, which is currently being built on GitHub and should arrive on PyPI soon.dchaplinsky commentedon Aug 17, 2022
Wow, many thanks!
dchaplinsky commentedon Oct 11, 2022
mrabarnett commentedon Oct 11, 2022
Given the feedback on python-dev, I won't be adding
\yand\Y. What I've already added should suffice.dchaplinsky commentedon Oct 11, 2022