I have a string of source code HTML.
So I would go:
int X = find indexof("theterm");
thesourcecode = thesourcecode.Substring(????
How can I delete all chars from the point where theterm is found BEHIND? Thanks SO.
Edit: An example so people dont’ get confused.
Sample string: “The big red house is so enormous!”
int Position = sampleString.IndexOf(“house”);
(pseudocode) From point Position, and back, delete everything:
Result string after my method: “is so enourmous!
THe code below assumes that this will change, otherwise I would have used the number 10 instead of
mySearchString.Length.Once you’ve found the index it’s easy:
Remove all the text before your string
or remove all the text after your search text.