Register  |  Login




Advertisement

Start Your Own Q&A Site

Create your own Q&A site easily, allowing you to quickly grow a new community around any subject matter or generate new organic traffic for your existing website.

Question

Status: Open Points: 125 Time: 05:47 - Mar 01, 2008  

deep0607

how i split a string if it has two differnt symbol as "," &"-"

i have a string as
my_string="java-3,os-2,internet-4,c-1,ospm-2"

i want that each subject name and digit comes into different array
how it, i can do

Categories

Answer Discussion
Tutorials

 

Mustafa

Date:: Mar 26, 2009

Time:: 06:24

You can not access a function from usercontorl class unless you have instance of it in your page and the function is public. e.g. (usercontorl1.function1())

otherwise, you should have that function in a class inside AppCode

Mustafa

Date:: Mar 26, 2009

Time:: 17:41

Sorry, for this mistake post
Anyway, no direct way to do this. However, there is two methods coming to my mind to this. first one be use "," and "-" as seperator which will split them to one array {java, 3, os, 2...}.
string[] array = input.Split(",-".ToCharArray());

The back draw of this method is the consistency if the input is inconsistence (e.g. java-3,os,internet-4,5-6-1,ospm-2).

Second method is the following

string[] array2 = input.Split(',');
List<string> set1 = new List<string>();
List<string> set2 = new List<string>();

for (int i = 0; i < array2.Length; i++)
{
string[] temp = array2[i].Split('-');
if (temp.Length == 2)
{
set1.Add(temp[0]);
set2.Add(temp[1]);
}
}

admin

Date:: Apr 17, 2009

Time:: 18:32

The question looks to be abandoned by the user who asked it. If no action is taken within 2 days, a Quomon Moderator will consider closing the question and distributing the points.

The Quomon Team

Answer this Question

New User

Email:

Upon submission of this form, you will automatically be registered as a Quomon user and we will send your login information to this address

Registered User

Username:

Password:

Forgot Your Password?

Tutorials cannot be submitted until the Answer Discussion is complete.

Submit answers in the Answer Discussion area

Ask a Question

Have a new question? Ask!

You have 100 characters to use



Top Experts

View More

Rank

Expert

Points

1.

nidhi

10354

2.

oracleofDelphi

6493

3.

rcastagna

5596

4.

LAGM

4848

5.

PeterNZ

3487

6.

gonzalo

2840

7.

Mason

2770

8.

jgivoni

2303

9.

xarcus

1820

10.

Anpanman

917

Become an Expert

Register today to share your knowledge with the community and be recognized and rewarded for your contributions.


Register Here




"Psst, Quomon is a great site. Pass it on."     Tell a Friend  |   Link To Us  |   Save to Delicious  |   Digg! Digg it



Language Options

English:

www.quomon.com

Español:

www.quomon.es