I found this code on the web
# Python code to find the URL from an input string
# Using the regular expression
import re
def Find(string):
# findall() has been used
# with valid conditions for urls in string
regex =
r"(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'\".,<>?«»“”‘’]))"
url = re.findall(regex,string)
return [x[0] for x in url]
# Driver Code
string = 'My Profile:
https://auth.geeksforgeeks.org/user/Chinmoy%20Lenka/articles in the portal
of http://www.geeksforgeeks.org/'
print("Urls: ", Find(string))
On Wednesday, May 12, 2021 at 1:22:01 AM UTC-6 Manuele wrote:
> Hi!
>
> I have a quite specific question... can anyone help me to implement a
> validator that reject all text containing a URL inside?
>
> Some spammers are annoying me registering some fake account introducing
> links in registration fields such like first name, last name... I hope
> in this way to limit it. Adding Google reCaptcha v2 to the registration
> forms didn't help.
>
> Thanks a lot
>
> Manuele
>
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/web2py/91925a1b-ed3e-46e8-9f75-b9d6949656c7n%40googlegroups.com.