I'm converting a C# function to Python. It's should bug for bug compatible with exist function.
This is a regex in that function: http://[a-zA-Z0-9]+(\.[a-zA-Z0-9]+)+([-A-Z0-9a-z_$.+!*()/\\\,:;@&=?~#%]*)*
. But Python can't compile it:
>>> re.compile(r"http://[a-zA-Z0-9]+(\.[a-zA-Z0-9]+)+([-A-Z0-9a-z_$.+!*()/\\\,:;@&=?~#%]*)*")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.3/re.py", line 214, in compile
return _compile(pattern, flags)
File "/usr/lib/python3.3/re.py", line 281, in _compile
p = sre_compile.compile(pattern, flags)
File "/usr/lib/python3.3/sre_compile.py", line 498, in compile
code = _code(p, flags)
File "/usr/lib/python3.3/sre_compile.py", line 483, in _code
_compile(code, p.data, flags)
File "/usr/lib/python3.3/sre_compile.py", line 75, in _compile
elif _simple(av) and op is not REPEAT:
File "/usr/lib/python3.3/sre_compile.py", line 362, in _simple
raise error("nothing to repeat")
sre_constants.error: nothing to repeat
Note: There is a JavaScript version of that regex: /http:\/\/[a-zA-Z0-9]+(\.[a-zA-Z0-9]+)+([-A-Z0-9a-z\$\.\+\!\_\*\(\)\/\,\:;@&=\?~#%]*)*/gi
.
I searched about
Sorry, this is a duplicate post.nothing to repeat
Error, but got nothing.
Where is the problem?