| |||
![]()
|
![]() ![]() |
![]()
URL-matching regex In case anybody needs it: here is a URL-matching regex, which is a modification of this one (surprisingly, I could not find good solutions on the web, and that was the best one I found). It seemed to have a minor bug, which is hopefully fixed in my version. in python notation: urlmatch=re.compile(ur'''(?i)\b(https?:/ (?: \( [^\s()<>]* (?: \( [^\s()<>]* \) [^\s()<>]* )* \) [^\s()<>]*)* ( ( \( [^\s()<>]* (?: \( [^\s()<>]* \) [^\s()<>]* )* \) ) | [^\s`!()\[\]{};:\'".,<>?\xab\xbb\u201c\u It only searches for URLs starting with "http://" or "https://" and with only two levels of nested brackets. If you need a more intelligent regex detecting strings like "www.example.com", you can use the beginning from the original code. Let me know if you find any examples where this regex fails. |
||||||||||||||
![]() |
![]() |