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


String Parse Question

Posted on 2008-06-23
Medium Priority
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


without the x this time for the strings I need.  Thanks so much
Question by:sbornstein2
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
LVL 18

Accepted Solution

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


Author Comment

ID: 21848580
how do I get the first part.
LVL 18

Expert Comment

by:Joel Coehoorn
ID: 21848891
LVL 30

Expert Comment

ID: 21850728
I'd also call Trim() on each part as these parts may have trailing  (or might be starting) spaces:


Author Closing Comment

ID: 31469823
awesome thanks a lot

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