Solved

String Parse Question

Posted on 2008-06-23
5
161 Views
Last Modified: 2013-11-05
hello all.  I have two fields a work phone and work extension textbox.  I am going to concat these together and place a "x" then the extension if the textbox is not null.  I then need to figure out how to string parse it to get the work phone and extension seperate any idea?

781-232-3233 x1234

781-233-3233
1234

without the x this time for the strings I need.  Thanks so much
0
Comment
Question by:sbornstein2
  • 2
  • 2
5 Comments
 
LVL 18

Accepted Solution

by:
jcoehoorn earned 250 total points
Comment Utility
Look at string.Split():

string phone = "781-232-3233 x1234";

string[] phoneparts = phone.Split(new char[] { 'x' }, 2);

Open in new window

0
 

Author Comment

by:sbornstein2
Comment Utility
how do I get the first part.
0
 
LVL 18

Expert Comment

by:jcoehoorn
Comment Utility
phoneparts[0]
0
 
LVL 29

Expert Comment

by:anarki_jimbel
Comment Utility
I'd also call Trim() on each part as these parts may have trailing  (or might be starting) spaces:

phoneparts[0].Trim()
0
 

Author Closing Comment

by:sbornstein2
Comment Utility
awesome thanks a lot
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

763 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

6 Experts available now in Live!

Get 1:1 Help Now