Help with Javascript RegExp
mpmcleod
Registered Users Posts: 288 Major grins
I am having some problems with making RegExp work in both FF and IE. Specifically it has to do with the /.
In FF the following works fine:
replaceText = new RegExp(">save photo</a>\\s*\\|");
if ( replaceText.test(document.body.innerHTML) == true) {
}
but it doesn't work in IE nor in Opera.
I have tried escaping the / by using 1,2 and 3 \ but none works.
What I am trying to do is shown here:
http://mpmcleod.smugmug.com/gallery/1470992
Currently I have a second routine that is called which checks '>save photo<' and replaces just that text for IE and Opera.
thanks for any help or ideas.
In FF the following works fine:
replaceText = new RegExp(">save photo</a>\\s*\\|");
if ( replaceText.test(document.body.innerHTML) == true) {
}
but it doesn't work in IE nor in Opera.
I have tried escaping the / by using 1,2 and 3 \ but none works.
What I am trying to do is shown here:
http://mpmcleod.smugmug.com/gallery/1470992
Currently I have a second routine that is called which checks '>save photo<' and replaces just that text for IE and Opera.
thanks for any help or ideas.
-- Mike
smugmug nickname: mpmcleod
http://www.michaelmcleod.com/
smugmug nickname: mpmcleod
http://www.michaelmcleod.com/
0
Comments
Sorry it's early here....i will look when I get to work and have had some coffee.
Cheers,
David
SmugMug API Developer
My Photos
replaceText = new RegExp(">save photo<\\/a>\\s*\\|");
Personally, I don't like this RegExp syntax since u need to use double \.
The alternative way is...
replaceText = />save photo<\/a>\s*\|/
Hope this helps,
David
SmugMug API Developer
My Photos
IE/ Opera both REQUIRE the /i flag even though the match is lowercase.
while FF is smart enough to know it is not needed.
works in both while leaving off the ignore case flag breaks it in IE/Opera....
Thanks for the help.
Edit: The first part of the code is wrong. Dgrin keeps editing it and removing the a tag. Even wrapped with code tags the tag still gets removed.
smugmug nickname: mpmcleod
http://www.michaelmcleod.com/