Solved

String Parse Question

Posted on 2008-06-23
5
167 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
[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
  • 2
  • 2
5 Comments
 
LVL 18

Accepted Solution

by:
jcoehoorn earned 250 total points
ID: 21847771
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
ID: 21848580
how do I get the first part.
0
 
LVL 18

Expert Comment

by:jcoehoorn
ID: 21848891
phoneparts[0]
0
 
LVL 30

Expert Comment

by:anarki_jimbel
ID: 21850728
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
ID: 31469823
awesome thanks a lot
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
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.
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

687 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