AS3 | Flash CS6 | Adobe Air 3.5
I have a very long string that will eventually be formatted as XML. In the string I have several instances of something along the lines of:
<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>
I need to search and replace all of these:
<title>(whatever is here)</garbage>
And make them:
<title>(whatever is here)</title>
As you can see I can’t simply search and replace “garbage” beacuse it wouldn’t apply in every single instance… I only want to replace the ones that use < title > …not < another title > Also please note that it is uncertain what characters will be between < title > and < /garbage >
So although I know this doesn’t work… I was thinking something along the lines of:
str = str.replace(/<title>\w+<\/garbage>/, "<title>\w+<\/title>");
I think the answer is under “Capturing sub-strings” on this page but so far no luck:
http://www.sevenson.com.au/actionscript/testing-regular-expressions/
It seems like at this point I’m just plugging in random things so it makes more sense to just ask for help.
Any advice is appreciated.
Match any symbol after
<title>and before</garbage>Example http://regexr.com?33nog