[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Search string - "," Vs ",,"

Posted on 2009-04-07
2
Medium Priority
?
167 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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month20 days, 6 hours left to enroll

872 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