0

I have one table pages which has url field. I want to filter those records by domain name. Below are the sample domains from list of URL.

I checked this answer. But REGEXP_REPLACE is not working in where condition.

Below is the query that I tried but it is only allowing to filter by hostname, I want regex which work for the domain name.

Page.where("substring(url from '.*://([^/]*)') in (?)", ['test.host'])

The request parameter for domains will be ['http://test.host'] not ['test.host'].

I am looking for the best solution to tackle this problem. Thank you in advance.

Vishal
  • 7,113
  • 6
  • 31
  • 61
  • This is a potential duplicate of https://stackoverflow.com/questions/21173734/extracting-top-level-and-second-level-domain-from-a-url-using-regex – max Apr 22 '20 at 11:33
  • @max I think you didn't get my question. I want a full domain with the scheme. Currently what i missing is scheme part and above question is not matching anywhere. – Vishal Apr 22 '20 at 12:47

0 Answers0