Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的磁盘上有一堆 html,我知道它们每个的绝对地址,现在我想让 src=" "、href=" " 的每个实例在 a、script、img、iframe 等标签内指向如果给定的路径是相对的,则为绝对补丁。
我不知道通过正则表达式、preg_match_all 等最快的方法是什么?我希望这个脚本能够识别“../../somefile.html”之类的路径。
我认为您将需要正则表达式和脚本的组合,因为我不认为正则表达式可以自己做到这一点
但是,如果您使用 ../ 获取正则表达式来提取 HREF,则使用脚本来计算文件夹并替换为您所需的 URL。