tags:

views:

23

answers:

2

Hi,

I need some RegExp help for a Flex 3 website. I'm trying to find this:

px;'</img>

And replace it with:

px;'></img>

I've tried:

var tester: String = " blah height: 0px;'<\img>blah";                           

var pattern1:RegExp = /px;'<\/img>/g;
tester = tester.replace(pattern1, "px;'></img>");

I think that the problem is with escaping the / in the img tag, but I'm not sure.

Any suggestions?

Thank you.

-Laxmidi

+2  A: 

No need for regexp:

tester = tester.replace("px;'</img>", "px;'></img>");

As a rule of thumb, don't use regex unless what you are looking for is variable.

quantumSoup
Hi quantumSoup, thank you for the post. Unfortunately, in this case, I have to use the dreaded RegExp as I have a few places where it needs to be changed. Thanks
Laxmidi
+2  A: 

Your regex looks right. Your test string, on other hand, has a backslash instead of a forward slash:

var tester: String = " blah height: 0px;'<\img>blah";                           
John Kugelman
John, thanks so much for the message. I missed the mistyped slash and thought that I had a problem with the escape.
Laxmidi