Link to home
Start Free TrialLog in
Avatar of Jimbo456
Jimbo456

asked on

String question

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
ASKER CERTIFIED SOLUTION
Avatar of eternal_21
eternal_21

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dfiala13
dfiala13

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);
The regular expression is safer. When there is no space the regex will not match but the Substring will raise an IndexOutOfRangeException.