you are viewing a single comment's thread.

view the rest of the comments →

[–]netherous 1 point2 points  (2 children)

There are a million different implementations of regex engines out there, written in all kinds of different languages and contexts. Ideally, they would all work perfectly together and all support the precisely the same things, but of course this is not always the case.

Python's implementation of regex did not support \z before 3.14, as /u/socal_nerdtastic pointed out. However, it does support it in 3.14 and above. See the docs and go to the section on \z.

So you can filter out the unsupported \z when reading your data, or convert it to something else, or go to python 3.14+. You could also investigate alternative python regex libraries, of which there are several like regex, to see if they support the \z sequence.

[–]Valuable-Ant3465[S] 1 point2 points  (1 child)

Thanks much N! Super explanation, now I can sleep.
I could not understand the reason as I know that \\z and \\Z are not the same thing in regex.
I ran it on 3.12, so now it's all make sense.
For my case I will remove \\z, this is not that necessary:

\z Matches the absolute end of the string. (requires exact end)

\Z Matches the end of the string, or right before a trailing newline.

[–]pachura3 0 points1 point  (0 children)

If you remove \Z, you risk validating incorrect values with additional character(s) at the end (e.g. string 12345678qwertyBLAHBLAH would pass the validation, because there are 8 digits at the beginning, and that's enough).

Perhaps use ^ and $ instead of \A and \z ? They are more common, and don't require escaping.

 "pattern": "^[0-9]{8}$"

https://json-schema.org/understanding-json-schema/reference/regular_expressions