【发布时间】:2013-02-11 06:15:12
【问题描述】:
AS3 |闪光 CS6 | Adobe Air 3.5
我有一个很长的字符串,最终会被格式化为 XML。在字符串中,我有几个类似以下内容的实例:
<title>Some title</title>
//the following line would need changed
<title>Some title</garbage>
<title>Some title2</title>
<title>Some title3</title>
//the following line would need changed
<title>Someone's title & (his info)</garbage>
//the following line should NOT change
<another title>something else</garbage>
我需要搜索并替换所有这些:
<title>(whatever is here)</garbage>
然后制作它们:
<title>(whatever is here)</title>
如您所见,我不能简单地搜索和替换“垃圾”,因为它不适用于每个实例...我只想替换那些使用
因此,尽管我知道这行不通……但我的想法是:
str = str.replace(/<title>\w+<\/garbage>/, "<title>\w+<\/title>");
我认为答案在此页面上的“捕获子字符串”下,但到目前为止还没有运气: http://www.sevenson.com.au/actionscript/testing-regular-expressions/
此时我似乎只是在随机插入一些东西,所以寻求帮助更有意义。
感谢任何建议。
【问题讨论】:
标签: actionscript-3 flash air flash-cs5