I saw this expression in another codebases library as part of the following sequence:
var url = sel.anchorNode.parentNode.href;
var match = self.location.href.replace(/\/$/i, '');
var replaced = url.replace(match,'');
It was suggest that the regular expression might strip of the trailing path to just reutrn the base URL but I created a fiddle to test that theory and it doesn't seem to check out.
It only strips the trailing slash. A single slash /
正则表达式会删除斜杠(如果有的话),但是与最后一行( replaced = ...
)结合使用时,将获得链接的URL和当前页面的URL(如果有斜杠,则将其删除) )从其中删除。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.