Solved

Search string - "," Vs ",,"

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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

777 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