Solved

String question

Posted on 2004-04-20
4
212 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

757 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

22 Experts available now in Live!

Get 1:1 Help Now