Solved

Search string - "," Vs ",,"

Posted on 2009-04-07
2
162 Views
Last Modified: 2012-05-06
I have a sting - which sometimes will contain values seperated by a single comma (,) and other times values seperated by double commas (,,)

I know how to do this - Contains(","))
but if seems like it is obviously also catchinginstances where ,, exist

Question is - how can I differentiate between the two instances?
0
Comment
Question by:tbaseflug
[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 Comments
 
LVL 39

Accepted Solution

by:
abel earned 500 total points
ID: 24088776
something like this:



if (myStr.Contains(",,"))
{
    // do some things for strings separated by double comma
} else
{
    // do some things for strings separated by single comma
}

Open in new window

0
 
LVL 39

Expert Comment

by:abel
ID: 24088806
Or, if your situation contains situations where you have strings where values are separated by one or two comma's, but also where other values exist.

The basic thought is: start out with testing for the most specific situation, then go to the less specific situation.

if (myStr.Contains(",,"))
{
    // do some things for strings separated by double comma
} elseif (myStr.Contains(","))
{
    // do some things for strings separated by single comma
} else
{
    // so some things for strings with no commas
}

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…

730 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