473,503 Members | 12,175 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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!
Nov 20 '05 #1
4 12575
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 in message
news:eX**************@TK2MSFTNGP10.phx.gbl...
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!

Nov 20 '05 #2
"Brian Henry" <brianiup[nospam]@adelphia.net> schrieb
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

Nov 20 '05 #3
* "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/>
Nov 20 '05 #4
thanks everyone, didn't realize you could trim characters like that
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:c7************@ID-208219.news.uni-berlin.de...
* "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/>

Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
13756
by: david | last post by:
Hi, I have an application as follows: MySQL database Back-Eend linked to MS Access Front-End and ASP Web Application. I require users to enter Serial Numbers such as: 0105123567 (10...
5
11483
by: samik_tanik | last post by:
I need to export a datagrid to Excel. I could did this. But, also need to keep the leading zeros in the data. How can I acheive this? Any help would be appreciated. -- Thanking you in...
1
4539
by: mmmgood1 | last post by:
Help, I'm linking an excel spreadsheet in access and I have datafields with leading zeros (01021). When the file is linked in access, I get a #num in the field with the leading zeros. The zeros...
1
12764
by: Joshua Ammann | last post by:
Hello, I'm trying to export a query containing contact information, including a field. Some zip codes have one or two leading zeros, for example, San Juan, PR (00927) and Springfield, MA...
6
5284
by: Clint Stowers | last post by:
Using A2k Exporting a query to a CSV file. The problem is any text fields (i.e. 000345) lose any leading zeros. Exporting to an excel file this problem does not exist. Tried to create a...
5
20389
by: OneDay | last post by:
I've got a field that has some old data with text in it, but all forward data will be a 3 digit number. But many of the numbers are still only 2 digits. I would like to force the leading zero in...
3
3069
by: LFM | last post by:
I am sure there is a simple answer. I have a database that where I am trying to setup a security login based on employee number. Employee number is a 5 character numeric field. The databse...
6
7734
by: JimmyKoolPantz | last post by:
Task: Customer wants a script of the data that was processed in a "CSV" file. Problem: Zip-Code leading zeros are dropped Basically we have a client that has requested a custom script for...
5
3424
by: Rowan | last post by:
Hi, I am somewhat new to .net and c#. (What I learned in previous co has to be unlearned). I am doing something that seems simple but I think there is a better way than how I learned to do it. ...
0
7193
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7067
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7316
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7449
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5562
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3148
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1495
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
728
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.