regex - How to validate LinkedIn public profile url regular expression in python -


i jus want validate linkedin public profile url. tried concept below

 = "https://in.linkedin.com/afadasdf"  p = re.compile('(http(s?)://|[a-za-z0-9\-]+\.|[linkedin])[linkedin/~\-]+\.[a-za-z0-9/~\-_,&=\?\.;]+[^\.,\s<]')  p.match(a) 

the above concept working fine. when give url https://www.linkedin.com means it's not working. can me validate both concepts.

it oring between http(s) , www. has given above problem. change them * (i.e. 0 or more).

import re  = "https://www.linkedin.com/afadasdf" p = re.compile('((http(s?)://)*([a-za-z0-9\-])*\.|[linkedin])[linkedin/~\-]+\.[a-za-z0-9/~\-_,&=\?\.;]+[^\.,\s<]') print p.match(a) 

although might want restrict www rather numbers or letters? maybe:

p = re.compile('((http(s?)://)*([www])*\.|[linkedin])[linkedin/~\-]+\.[a-za-z0-9/~\-_,&=\?\.;]+[^\.,\s<]') 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -