如何添加链接标题作为img的alt。使用正则表达式并在Dreamweaver中。我必须在一份大文件中做。并在多个文件中
在
<a title="Whatever is written here" href="#" target="_blank">
<img width="14" height="14" src="#" /></a>
后
<a title="Whatever is written here" href="#" target="_blank">
<img width="14" height="14" src="#" alt="Whatever is written here" /></a>
答案 0 :(得分:1)
尝试搜索
(<a[^>]+?title=")([^"]*)("[^<]+<img)
并替换为
$1$2$3 alt="$2"
这假设<a>
标记和<img>
标记之间没有其他标记,并且title
属性中没有(转义)引号。
编辑:将\1
反向引用语法更改为$1
。
答案 1 :(得分:0)
执行此操作的最佳方法是使用以下编写语言(ruby,python等)编写脚本:
已经有一些libraties来解析html / xml(例如ruby.hpricot)