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
Regular expressions use the backslash character ('') to indicate special forms or to allow special characters to be used without invoking their special meaning. This collides with Python’s usage of the same character for the same purpose in string literals; for example, to match a literal backslash, one might have to write '\\' as the pattern string, because the regular expression must be \, and each backslash must be expressed as \ inside a regular Python string literal. Also, please note that any invalid escape sequences in Python’s usage of the backslash in string literals now generate a DeprecationWarning and in the future this will become a SyntaxError. This behaviour will happen even if it is a valid escape sequence for a regular expression.
👋 @zormit thanks for reaching out, I'm marking this for the next major version of the SDK so that it stays on our radar, but if it's a fix that doesn't break compatibility with python 3.5, we'll do our best to get it in the current major version of the SDK (v4).
The solution you proposed would mean, both the following strings are stored identically in memory with no concept of whether they were raw or not, for example:
Both these strings contain \d and there is nothing to say that this came from a raw string. So when you pass this string to the re module it sees that there is a \d and sees it as a digit because the re module does not know that the string came from a raw string literal.
There is a use-case to proceed with caution and I agree with @hollabaq86.
General information
Issue description
According to https://docs.python.org/3/library/re.html, some of the regex strings might lead to syntax errors in future python versions:
For example:
I think the solution is just to convert all regex strings to the raw
r"..."
format. But I'm not sure on backwards compatibility on that...The text was updated successfully, but these errors were encountered: