This is my python code line which is giving me invalid escape sequence '/' lint issue.
pattern = 'gs:\/\/([a-z0-9-]+)\/(.+)$' # for regex matching
It is giving me out that error for all the backslash I used here . any idea how to resolve this ?
This is my python code line which is giving me invalid escape sequence '/' lint issue.
pattern = 'gs:\/\/([a-z0-9-]+)\/(.+)$' # for regex matching
It is giving me out that error for all the backslash I used here . any idea how to resolve this ?
There's two issues here:
\/
is not a valid string escape sequence, you get that warning. Use a raw string so that the backslashes will be ignored by the string parser and passed to the regexp engine. See What exactly is a "raw string regex" and how can you use it?/
is part of the regular expression syntax (it's the delimiter around the regexp), so they need to be escaped. But Python doesn't use /
this way, so there's no need to escape them in the first place.Use this:
pattern = r'gs://([a-z0-9-]+)/(.+)$' # for regex matching