I wanna check if a url string match keyword, for example, keyword is google.com
, if url string is google.com
or https://google.com
, then return true
, if url is google.com/search
or something like that, return true
, if url is google.com.id
, then return false
as it's a different url, I tried one as below but it doesn't work, how to write regular expression? thank u
regexp.MatchString(`^(?:https?://)?([-a-z0-9]+)(?:\.`+keyword+`)*$`, urlstr)
btw, as far as I understood, regular expression will cause some performance issue, anyone can provide other solutions to handle it?