Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trim string from beginning to substring c#

Tags:

string

c#

I am having trouble cutting down my string. I have a windows form application that receives incoming data. So far the examples I have found all use char to locate. I need to have it search for the entire "*S" and not just one character of it.

I did find a way to get the index of the sting and trim from that point to the end (sting.remove). My problem is i need to trim the beginning. so a trim to index method would work but I haven't found how to do that.

What i have is a bunch of data like

"ok \r\n *S 38773 get 3042"

What I need to do is locate the *S and remove everything from the beginning to the *S. Because the return is not always the same I cant use replace or remove methods. I cant predict what will come before the *S and the remaining data is dynamic.

Any examples on how to essentially trim start to the "*S" would be wonderful. Thank you.

like image 495
eatumup Avatar asked Dec 09 '22 03:12

eatumup


1 Answers

s = s.Substring(s.IndexOf("*S"));
like image 168
SLaks Avatar answered Dec 23 '22 21:12

SLaks