[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

String Parse Question

Posted on 2008-06-23
5
Medium Priority
?
169 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:
Joel Coehoorn earned 1000 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:Joel Coehoorn
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

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

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

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

656 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