If I have a string the is always preceded by http://
, and optionally folowed by /
. Example:
http://www.mymovies.com/
But sometimes can be in the format: http://www.mymovies.com
I want to extract www.mymoviews.com
I want to capture both format (with/without the /
)
I tried using:
import re
print(re.search('http://(.*)/','http://www.mymovies.com').group(1))
But I get this error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'group'
1) How to solve the error
2) How to capture both with/without the following /
character (as my solution requires /