views:

131

answers:

2

I have a string named group.

string group="|17|11|";

So my issue is that I want my output to be something like this:

17
11

so these 2 numbers should be stored in the database as two records. and another case if the

 string group = "|17|11|05|";

it will store 3 values in the database. The number of groups always differs in different strings it can be 1 or many.

17
11
05

the database structure is like this:
id, group

Thanks. Hope to hear from you guys soon.

A: 

Since the language isn't specified, I'll throw out the first idea that comes to my head.

In .Net, you'd use String.Split()

Odds are, the language you're using has something similar.

David Stratton
A: 

I solved it!!

Thank your comments and suggestions..I'll improve the way I question.. HAHAH I hope you guys and gals get the logic. Quite simple :)

        string group = "|17|11|05|";
        string[] words = group.Split('|');
        foreach (string word in words) {
            if (word.ToString() != "") {
                string cg = word;
            }
        }
Ravi
You know you don't need to keep calling `ToString` on `word`? It's already a string...
Greg Beech
yea yea my bad haha
Ravi