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
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";
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.
精彩评论