开发者

Regex to replace document.all

A simple (I hope) regex question:

I have several pages where I need to replace every document.all['string'] with document.getElementById('string').

I can use Visual Studio or Notepad++ to replace regular expressions, I just need the r开发者_运维百科ight ones.

Thanks for any assistance, Guy


For notepad++:

search:

document\.all\[\'(.*)\'\]

replace with:

document.getElementById('\1')


Replace

document\.all\['(.*?)'\]

by

document.getElementById('$1')

The parentheses are used to identify a group. The $1 is used to print the value of the first group. The backslashes are used to escape special characters in regex. For the remnant it's pretty trivial.

Hope this helps.


Search for:

document\.all\['([^']+)'\]

Replace with:

document.getElementById('\1')
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜