I would like to match just the root of a URL and not the whole URL from a text string.
(我想只匹配URL的根,而不匹配文本字符串中的整个URL。)
Given:(鉴于:)
http://www.youtube.com/watch?v=ClkQA2Lb_iE
http://youtu.be/ClkQA2Lb_iE
http://www.example.com/12xy45
http://example.com/random
I want to get the 2 last instances resolving to the www.example.com
or example.com
domain.
(我想将最后2个实例解析为www.example.com
或example.com
域。)
I heard regex is slow and this would be my second regex expression on the page so If there is anyway to do it without regex let me know.
(我听说正则表达式很慢,这将是我在页面上的第二个正则表达式表达式,因此,如果仍然需要不使用正则表达式,请告诉我。)
I'm seeking a JS/jQuery version of this solution.
(我正在寻找此解决方案的JS / jQuery版本。)
ask by Chamilyan translate from so