Basically I am updating an old web app to be multi browser compliant. All over the place the original programmers have used -
document.all.element
As I understand the ".all" is IE only, introduced in IE 4. The standards compliant ".getElementById" function was introduced in IE 5. I want to change instances of the above statement to -
document.getElementById("element")
How would I form this regular expression, specifically using Visual Studio's "Find and Replace" dialog?
In Visual Studio 2010 and earlier the regular expression syntax is following:
To tag an expression use { }
, to reference first tag for replacement use \1
In your case you need to find:
document\.all\.{[a-zA-Z0-9]+}
and replace with:
document.getElementById('\1')
In Visual Studio 2012 the regular expression syntax has changed to:
document\.all\.([a-zA-Z0-9]+)
document.getElementById('$1')
I'm not sure if this is an issue with me using Visual Studio 2012 RC but using braces failed to match to anything.
I ended up using the find expression -
document\.all\.([a-zA-Z0-9]+)
and the replacement
document.getElementById("$1")
The "$1" refers to the bracketed expression.
Thanks for your help guys.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With