I have this regex, which extracts domain name from string.
var matches = str.match(/^https?\:\/\/([^\/:?#]+)(?:[\/:?#]|$)/i);
I would like the same RegEx, including other protocols like rstp. For example:
"http://www.example.com/a/".match(/^https?\:\/\/([^\/:?#]+)(?:[\/:?#]|$)/i)
Result: ["http://www.example.com/", "www.example.com"]
I have tried this:
"http://www.example.com/a/".match(/^(http|https|rtsp)\:\/\/([^\/:?#]+)(?:[\/:?#]|$)/i)
But it returns http too: ["http://www.example.com/", "http", "www.example.com"]
I would like the same output.
Thanks.