Regex doubt - Advanced Regular Expresion exercice 8

Hi, I’m trying to solve the exercice 8-12 from advanced regular expresions. and couldn’t find the solution.
I did this regular expresión:
test_urls_clean = test_urls.str.extract(r’((?<=[css-])?[w{3}.]?\w+.\w+[.\w+]?\w+)’)

but the css- from the last url didn’t fit at all.
So I went to the answer and checked without the flag re.I to ignore case sensitive and find out that not all of the urls appeare as an example of github.com.
So I don’t understand why is it happening. Ignorecase sensitive shouldn’t be just when all the letters are not lower or uppercase?
Screen Link:

Thanks.

Kindly provide a link to the problem.

Hi @monorienaghogho,

This is the link https://app.dataquest.io/m/369/advanced-regular-expressions/8/extracting-domains-from-urls

This pattern worked with flags=re.I in all str.extract():

pattern = r"https?://(?<=css-)?([\w\-\.]+)"

I tried to match step by step and it wasn’t very pretty at the end. I ended up with this regex pattern = r"https?://(\w+?\.?\w+\-?\.?\w+\.?[\w\.]+)"

It matched the test_url but still was not general enough to match hn[url].

Thank you @monorienaghogho!

I will try some other methods as I don’t understand yet what the flag “re.I” does to the string to match the right pattern.

Appreciate your help! Thank you Again!

1 Like