-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
elinkapi/utils.py:5: SyntaxWarning: invalid escape sequence '\/'
_ROR_ID_PATTERN = re.compile("^(?:(?:(http(s?):\/\/)?(?:ror\.org\/)))?(0[a-hj-km-np-tv-z|0-9]{6}[0-9]{2})$")This is because it's not a raw string.
This works:
_ROR_ID_PATTERN = re.compile(r"^(?:(?:(http(s?)://)?(?:ror\.org/)))?(0[a-hj-km-np-tv-z|0-9]{6}[0-9]{2})$")I don't think the / needs to be escaped at all but the "." does.
Example showing it working:
>>> _ROR_ID_PATTERN = re.compile(r"^(?:(?:(http(s?)://)?(?:ror\.org/)))?(0[a-hj-km-np-tv-z|0-9]{6}[0-9]{2})$")
>>> _ROR_ID_PATTERN.match("https://ror.org/048g3cy84")
<re.Match object; span=(0, 25), match='https://ror.org/048g3cy84'>
>>> _ROR_ID_PATTERN.match("https://ror.org/048g3cy84dfg ")
>>> Metadata
Metadata
Assignees
Labels
No labels