I have a line that looks like this: "texthere^D123456_02" . But I want my result to be D123456 .
this is what i am doing so far:
if (name.Contains("_")) { name = name.Substring(0, name.LastIndexOf('_')); }
With this, I delete at least _02 , however, if I try to do the same for ^ , then I always return texthere , even when I use name.IndexOf("^")
I also tried to check only ^ to get at least the result: D123456_02 , but still the same result.
I even tried name.Replace("^" , and then used the substring method that I used earlier. But again, the result remains the same.
texthere not always the same length, so .Remove() out of the question.
What am I doing wrong?
thanks
substring c #
Desutoroiya
source share