Solved

Search string - "," Vs ",,"

Posted on 2009-04-07
2
163 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

724 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