Regular expression to replace multiple parts of a string (in Visual Studio 2012)

Basically I am updating an old web application compatible with multiple browsers. In the whole place that the original programmers used -

document.all.element

As I understand it, “.all” is just IE introduced in IE 4. The “.getElementById” function was introduced in IE 5. I want to change the instances of the above statement to

document.getElementById("element")

How can I generate this regular expression, in particular, using the Find and Replace dialog of Visual Studio?

+5
source share
4 answers

I'm not sure if this is a problem with me using Visual Studio 2012 RC, but using curly braces doesn't work for anything.

I ended up using the find expression -

document\.all\.([a-zA-Z0-9]+)

document.getElementById("$1")

"$ 1" .

.

+2

Visual Studio 2010 :

, { }, \1

:

document\.all\.{[a-zA-Z0-9]+}

:

document.getElementById('\1')

Visual Studio 2012 :

document\.all\.([a-zA-Z0-9]+)
document.getElementById('$1')
+4

[.]all[.]{:i}

.getElementById("\1")

. , ( \.). :i - Visual Studio .

\1 (.. {:i}), "" .

+1

, .

Just replace document.all.elementwith document.getElementByIdin the text replace dialog

0
source

All Articles