?
Solved

String question

Posted on 2004-04-20
4
Medium Priority
?
228 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 10

Accepted Solution

by:
eternal_21 earned 1000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month13 days, 23 hours left to enroll

800 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