sebastiz
asked on
Problems with trim function
In VB.NET
I have a string which looks like this ",,,,,,,,,,,,,,,,,BL8,NW3, BL8)
I need to get rid of the leading commas and whitespaces. Any idea how I do this. Ive had no luck with the Trim function
Seb
I have a string which looks like this ",,,,,,,,,,,,,,,,,BL8,NW3,
I need to get rid of the leading commas and whitespaces. Any idea how I do this. Ive had no luck with the Trim function
Seb
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
To get rid of the 'leading commas...try this...
yourString=",,,,,,,,,,,,,, ,,,BL8,NW3 ,BL8)"
Dim strNew=yourString.replace( ","," ").trim.replace(" ",",")
This will replace all commas with a space, trim the results and then replace the remaining spaces with commas (to 'add' them back in)
yourString=",,,,,,,,,,,,,,
Dim strNew=yourString.replace(
This will replace all commas with a space, trim the results and then replace the remaining spaces with commas (to 'add' them back in)
string output = input.TrimStart(new char[] {','});