开发者

Regular expressions in Dreamweaver - producing a number sequence

I've got an HTML page with a long series of data in tabular format (2194 entries!), each starting with

<td id="foo"...> 

I need each id to be unique, and so would like to use a regular expression in Dreamweaver's find and r开发者_开发百科eplace function to do this. Basically, it would look like this before:

<td id="foo"...>
<td id="foo"...>
<td id="foo"...>

and, using the regular expression, changed to:

<td id="001"...>
<td id="002"...>
<td id="003"...>

Is this possible? And, if so, what's the syntax of the expression?

Thanks in advance!


Instead of using something like a simple find/replace from a text editor, I'd run it through some kind of HTML DOM script. Here's some jQuery-ish pseudocode:

var tdList = source.find('td.foo');

for (i = 0; i < tdList.length; i++) {
     tdList[i].attr('id', 'foo' + i.padWithZeroes(length:3));
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜