Click here to Skip to main content
15,891,951 members
Home / Discussions / C#
   

C#

 
GeneralRe: Event handling Pin
OriginalGriff21-Oct-10 9:50
mveOriginalGriff21-Oct-10 9:50 
QuestionX / OK intercetption Pin
neverpleat21-Oct-10 3:08
neverpleat21-Oct-10 3:08 
QuestionString split? Pin
SRKSHOME21-Oct-10 2:55
SRKSHOME21-Oct-10 2:55 
AnswerRe: String split? Pin
Abhinav S21-Oct-10 2:58
Abhinav S21-Oct-10 2:58 
GeneralRe: String split? Pin
SRKSHOME21-Oct-10 3:22
SRKSHOME21-Oct-10 3:22 
GeneralRe: String split? Pin
Abhinav S21-Oct-10 8:30
Abhinav S21-Oct-10 8:30 
AnswerRe: String split? Pin
PIEBALDconsult21-Oct-10 3:11
mvePIEBALDconsult21-Oct-10 3:11 
AnswerRe: String split? Pin
_Erik_21-Oct-10 5:14
_Erik_21-Oct-10 5:14 
A simple Split will work for every ',' character into the original string, and it seems that it should ignore the ones which are between parenthesis. You can use regular expressions to achieve this. First of all, replace every ',' character which is between parenthesis with another character easy to replace back when split is finished ('|' could be a good choice). Then make a normal split, and then replace back. This code would work for the sample given:

string originalString = "sdate=2,edate=3,,frq=price(sdate=0,,),curn=usd";
Regex r=new Regex("\\(.+\\)");

string modified = r.Replace(originalString, m =>
    { 
        return m.Value.Replace(',', '|'); 
    });

string[] vector = modified.Split(',');

for (int i = 0; i < vector.Length; i++)
    vector[i] = vector[i].Replace('|', ',');


Though vector[3] would be an empty string due to the two consecutive commas after the edate=3. If you want to ignore several consecutive commas into the string, you should make this before the split and after the replacement made by the Regex object:

while (modified.Contains(",,"))
    modified = modified.Replace(",,", ",");


Hope this helps. See you
GeneralRe: String split? Pin
SRKSHOME21-Oct-10 20:46
SRKSHOME21-Oct-10 20:46 
Questionsomething faster than GetPixel and SetPixel ? Pin
inayathussaintoori21-Oct-10 2:18
inayathussaintoori21-Oct-10 2:18 
AnswerRe: something faster than GetPixel and SetPixel ? Pin
Abhinav S21-Oct-10 2:56
Abhinav S21-Oct-10 2:56 
GeneralRe: something faster than GetPixel and SetPixel ? Pin
inayathussaintoori21-Oct-10 13:12
inayathussaintoori21-Oct-10 13:12 
QuestionSomething like DataGridViewCheckBoxColumn Pin
Dewald20-Oct-10 23:27
Dewald20-Oct-10 23:27 
AnswerRe: Something like DataGridViewCheckBoxColumn Pin
Goutam Patra21-Oct-10 0:43
professionalGoutam Patra21-Oct-10 0:43 
Questionupkey on serialport Pin
caradri20-Oct-10 23:05
caradri20-Oct-10 23:05 
AnswerRe: upkey on serialport Pin
Rajesh Anuhya20-Oct-10 23:26
professionalRajesh Anuhya20-Oct-10 23:26 
GeneralRe: upkey on serialport Pin
caradri21-Oct-10 3:10
caradri21-Oct-10 3:10 
GeneralRe: upkey on serialport Pin
Rajesh Anuhya21-Oct-10 3:51
professionalRajesh Anuhya21-Oct-10 3:51 
GeneralRe: upkey on serialport Pin
caradri21-Oct-10 4:29
caradri21-Oct-10 4:29 
AnswerRe: upkey on serialport Pin
Rajesh Anuhya21-Oct-10 19:15
professionalRajesh Anuhya21-Oct-10 19:15 
Questionusing wild card characters in batch file Pin
prasadbuddhika20-Oct-10 20:23
prasadbuddhika20-Oct-10 20:23 
QuestionRe: using wild card characters in batch file Pin
Peter_in_278020-Oct-10 20:25
professionalPeter_in_278020-Oct-10 20:25 
AnswerRe: using wild card characters in batch file Pin
prasadbuddhika20-Oct-10 20:42
prasadbuddhika20-Oct-10 20:42 
AnswerRe: using wild card characters in batch file Pin
Rajesh Anuhya20-Oct-10 20:46
professionalRajesh Anuhya20-Oct-10 20:46 
Questiondesktop notification Pin
kjgiiy20-Oct-10 16:08
kjgiiy20-Oct-10 16:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.