Replace() with a twist...
Posted on 2003-03-15
I've been having problems with a function that's based around Replace.
Given a String, with multiple occurances of a sub-string beginning and sub-string ending, I need to replace all parts of the substring that are within a sub-string beginning and ending.
Sounds rough. It's not that bad, here's an example:
newStr = "[SubString]Hello this is a [/SubString] string"
newStr2 = "[SubString]Hello is[/SubString] is another [SubString] string [/SubString]"
That's also fine.
But this one is bad, and would require replacement:
newStr3 = "[SubString]This is[SubString] a [/SubString] bad String.[/SubString]"
If should be modified to look like this:
newStr3 = "[SubString]This is a bad String.[SubString]"
Basically, any time you're within a SubString, there can be no other SubString parts. You can assume that every SubString beginning has a matching SubString Ending.
Anyone wanna take a stab at it? I'd give more points, but 40 is all I have, and this is a not-for-profit organization that I'm already losing money on, and cannot afford more (sorry!).