I have a string which I need to remove certain characters from.
string note = “TextEntry_Slide_7|Notepad one I am going to enter the text all over the place :)|250887|0^TextEntry_Slide_10|Notepad two: wrilun3q 4p9834m ggddi :(|996052|2^TextEntry_Slide_14||774159|4^TextEntry_Slide_16|tnoinrgb rt trn n|805585|5”
I want to remove the ^ characters and also the 9 characters behind the ^ character. So the string will look like:
string note = “TextEntry_Slide_7|Notepad one I am going to enter the text all over the place :)TextEntry_Slide_10|Notepad two: wrilun3q 4p9834m ggddi :(TextEntry_Slide_14|TextEntry_Slide_16|tnoinrgb rt trn n|805585|5”
Also after that I need to remove the last 9 characters off the end of the string:
string note = “TextEntry_Slide_7|Notepad one I am going to enter the text all over the place :)TextEntry_Slide_10|Notepad two: wrilun3q 4p9834m ggddi :(TextEntry_Slide_14|TextEntry_Slide_16|tnoinrgb rt trn n”
I’ve already removed a ton of other stuff that was originally in the string note but I am stumped on how to do the above.
I found the index of the ^ character like note.IndexOf("^") but I am unsure what to do next to remove the 9 characters before it.
Any help will be greatly appreciated 🙂
One simple way is
Regex.Replace(note, ".{9,9}\\^", "");And the obvious way to remove the last 9 characters would be
note.Substring(0, note.length - 9);