I have a string that is formed from tag-substitution, which also results in parts of the string being marked for deletion, for example:
Keep1
{/*DELETE}
Delete1a
{/*DELETE}
Delete2
{DELETE*/}
Delete1b
{DELETE*/}
Keep2
{/*DELETE}
Delete3
{DELETE*/}
Keep3
Am I correct that a RegEx cannot be used to select only the inner DELETE2 and DELETE3, remove those, and then repeat to get the DELETE1a/b until no further matches are found?
The RegEx I am passing to my replace function is
\{\/\*DELETE\}([\s\S]*?)\{DELETE\*\/\}
This matches
{/*DELETE}
Delete1a
{/*DELETE}
Delete2
{DELETE*/}
If this is the only RegEx match that I can make I could [suppress the leading {/*DELETE}
and] call the replace function recursively which, I think, would enable me to remove the nested {TAGS}
Is a better way?
I am using the RegEx in VBScript
EDIT: In case it helps I can change the {/*DELETE}
and {DELETE*/}
tags, even to a single character
EDIT2: I could use a single-character as the Start/End delete marker - if, for example, that would be faster for a RegEx expression to resolve e.g. by being less complex
e.g. if the Start-Delete is [
and then end delete is ]
Keep1
[
Delete1a
[
Delete2
]
Delete1b
]
Keep2
[
Delete3
]
Keep3
These characters chosen for appearance in this example, in practice they would occur within my real-world data, but I expect I could chose two ASCII values which do not appear in my data at all.
Clarification: The {DELETE} tags will not always appear on a line by themselves, so this style of string formation will also exist
Keep1{/*DELETE}Delete1a
{/*DELETE}Delete2{DELETE*/}
Delete1b{DELETE*/}Keep2a
Keep2b{/*DELETE}Delete3{DELETE*/}Keep3
or with single-character delete-tags:
Keep1[Delete1a
[Delete2]
Delete1b]Keep2a
Keep2b[Delete3]Keep3