removeing leading zeros in a text string (not a numeric field)

  • Thread starter Thread starter Brian Henry
  • Start date Start date
B

Brian Henry

Say I have a text string like

"0002323235-3434-3545" and I want to remove the leading zeros, would a
regular expression work here? sorry I haven't worked with regex's that much
and still need to get caught up on them :) if so how would you go about
doing that? thanks!
 
Check out the TrimStart method of the string class. You pass it a character
array of characters to remove - in this case, the array will have one
character, the "0".
 
* "Brian Henry said:
"0002323235-3434-3545" and I want to remove the leading zeros, would a
regular expression work here?

I would use this code:

\\\
Dim s As String = "000012"
MsgBox(s.TrimStart("0"c))
///
 
Back
Top