Reputation: 45
whats the code to cut or trim a string until a particular character is hit.
for example,
dim TestString as String = "REG - REGULAR"
output of this string after cutting should be,
"REG"
The code should be able to cut the string until it reaches this character "-".
It should also remove the white spaces. whats the code for doing this task.
I am using vb.net.
Thank You
Upvotes: 0
Views: 16547
Reputation: 30698
You can use String.Substring
TestString = TestString.Substring(0,TestString.IndexOf('-')).Trim()
Upvotes: 3