Solved

String question

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

Technology Partners: 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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

724 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