I want to search a long string for a string inside it that BeginsWith and EndsWith something, and then eventually replace it with a token.
So, let's say I have a string:
"This is text with a token: <TokenID=123>doesn't matter</Token>, and some more text!"
I'd like to extract/identify the following string:
<TokenID=123>doesn't matter</Token>
So that I can use it within a replace statement on the original string, to replace it with something else. The ID for this tag could be different, so I want to identify the string above by using something like:
var beginsWith = "<TokenID=";
var endsWith = "</Token>";
The BeginsWith and EndsWith values will be pulled from a CSV file into a list, as there are many of them with different content. Once I know how to extract these, I eventually want to replace them with a character that I could split on to create an array of strings around the extracted strings.
I don't want to use regex, as the BeginsWith and EndsWith strings need to be easily configurable and added to at a later stage.
This feels like it should be a really simple exercise, but for the life of me I can't figure out how to do it...