HighTechTalks DotNet Forums  

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

VB.net microsoft.public.dotnet.languages.vb


Discuss removeing leading zeros in a text string (not a numeric field) in the VB.net forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Brian Henry
 
Posts: n/a

Default removeing leading zeros in a text string (not a numeric field) - 05-04-2004 , 12:39 PM






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!



Reply With Quote
  #2  
Old   
Marina
 
Posts: n/a

Default Re: removeing leading zeros in a text string (not a numeric field) - 05-04-2004 , 12:43 PM






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" <brianiup[nospam]@adelphia.net> wrote

Quote:
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!





Reply With Quote
  #3  
Old   
Armin Zingler
 
Posts: n/a

Default Re: removeing leading zeros in a text string (not a numeric field) - 05-04-2004 , 12:43 PM



"Brian Henry" <brianiup[nospam]@adelphia.net> schrieb
Quote:
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!
msgbox "0002323235-3434-3545".trimstart("0"c)


--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html



Reply With Quote
  #4  
Old   
AT
 
Posts: n/a

Default Re: removeing leading zeros in a text string (not a numeric field) - 05-04-2004 , 12:55 PM



* "Brian Henry" <brianiup[nospam]@adelphia.net> scripsit:
Quote:
"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))
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>


Reply With Quote
  #5  
Old   
Brian Henry
 
Posts: n/a

Default Re: removeing leading zeros in a text string (not a numeric field) - 05-04-2004 , 03:14 PM



thanks everyone, didn't realize you could trim characters like that


"Herfried K. Wagner [MVP]" <hirf-spam-me-here (AT) gmx (DOT) at> wrote

Quote:
* "Brian Henry" <brianiup[nospam]@adelphia.net> scripsit:
"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))
///

--
Herfried K. Wagner [MVP]
URL:http://dotnet.mvps.org/



Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.