I am trying to extract hostnames from URLs by using the MySQL function REGEXP_SUBSTR.
The closest RegEx I got is the following:
(?:\w+\.)?(\w+\.\w+)
Which works relatively speaking, but the issue is that the captured hostname is grouped
Suppose we're trying to match https://www.w3schools.com/home, the above regex would return:
- Full match
www.w3schools.com - Group 1.
w3schools.com
REGEXP_SUBSTR seems to only subtract what is found in the "Full match" thus the above solution results incorrect.
How can I modify the above pattern in order to include the hostname in the Full match, rather than a Group?