Solved

String question

Posted on 2004-04-20
4
213 Views
Last Modified: 2011-09-20
I have a string such as
strAddress="509 Lincoln Drive";

How do I strip of the number and the space after it. It has got to be simple but I am a newby.

Jim
0
Comment
Question by:Jimbo456
4 Comments
 
LVL 10

Accepted Solution

by:
eternal_21 earned 250 total points
ID: 10874793
The code,

  System.Text.RegularExpressions.Regex.Replace("509 Lincoln Drive", @"^\d*\s*", "")

will return "Lincoln Drive".
0
 
LVL 12

Expert Comment

by:dfiala13
ID: 10874816
A couple of ways...

If you want to work with the parts/pieces of the string you can use the Split method or use regular expressions.
If you just want to get rid of everything to the left of the first space and the first space this will do it...

strAddressNoNum = strAddress.Substring(strAddress.IndexOf(" ")+1);
0
 
LVL 10

Expert Comment

by:ptmcomp
ID: 10876041
The regular expression is safer. When there is no space the regex will not match but the Substring will raise an IndexOutOfRangeException.
0
 
LVL 23

Expert Comment

by:rama_krishna580
ID: 10876088
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now