Reputation: 729
I'm using tags in a richtexteditor to specify data fields.
E.g [Start] and [End]
How can I remove a section of text between [Start] and [End] from a string block including the tags?
Is there an easier way rather than using IndexOf and Substring etc?
Update: I'm attempting to use var output = Regex.Replace("[Start]SomeText[End]", @"(?<=[Start]).*(?=[End])", "")
But the pattern does not quite work. It needs to remove everthing between [Start] and [End]
Upvotes: 0
Views: 651
Reputation: 2427
Consider using Regex to replace the text between [Start] and [End]. The following code snippet should help...
var output = Regex.Replace("[Start]SomeText[End]", @"(?<=\[Start\]).*(?=\[End\])", "");
Upvotes: 2
Reputation: 4808
You could use a Regular Expression, but I can't think of anything 'easier' than searching the file for it.
Upvotes: 0