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')
精彩评论