Guru110
Guru110

Reputation: 129

Getting substring through regexp in mysql query

I have tried all the things like regexp ,substring for getting domain name from uri 'http://start.readingresults.com/RapidResults/vocab_web_alt/reviewResponseAjax.do' but failed to get accurate result.It should show me www.start.readingresults.com.Somatimes uri includes ip address which make me this thing more complex.Such as 192.168.1.10 etc. Which is more proper way to find domain regexp or substring?

Upvotes: 0

Views: 270

Answers (1)

Sundar G
Sundar G

Reputation: 1069

SELECT SUBSTRING_INDEX(SUBSTRING_INDEX('http://start.readingresults.com/RapidResults/vocab_web_alt/reviewResponseAjax.do', '//', -1),'/',1);

if your URL having ip address means you have to handle in separate way using SUBSTRING_INDEX

Here the sqlfiddle.

Cheers...

Upvotes: 2

Related Questions