Click here to Skip to main content
15,900,563 members
Home / Discussions / C#
   

C#

 
AnswerRe: Unable to add event handler for Minimizing the Ribbon Control in WPF Pin
JF201515-Nov-11 3:27
JF201515-Nov-11 3:27 
QuestionSynchronous webservice calls briefly freeze up multithreaded application Pin
CDP180215-Nov-11 1:27
CDP180215-Nov-11 1:27 
AnswerRe: Synchronous webservice calls briefly freeze up multithreaded application Pin
BobJanova15-Nov-11 2:41
BobJanova15-Nov-11 2:41 
GeneralRe: Synchronous webservice calls briefly freeze up multithreaded application Pin
CDP180215-Nov-11 3:09
CDP180215-Nov-11 3:09 
QuestionCan anyone explain how this Regex works? Pin
fiaolle14-Nov-11 22:17
fiaolle14-Nov-11 22:17 
AnswerRe: Can anyone explain how this Regex works? Pin
PIEBALDconsult15-Nov-11 1:53
mvePIEBALDconsult15-Nov-11 1:53 
AnswerRe: Can anyone explain how this Regex works? Pin
BillWoodruff15-Nov-11 2:28
professionalBillWoodruff15-Nov-11 2:28 
AnswerRe: Can anyone explain how this Regex works? Pin
BobJanova15-Nov-11 2:47
BobJanova15-Nov-11 2:47 
It's basically saying 'split on space or on this big group which matches a quoted string'. I guess the fact it's a parenthesised group is how it ends up being returned even though it was the split expression. I don't fully understand it but that's the basic idea.

This isn't how I would parse a command string, I have some code for that in my Lobby Server article:
// Command line utility
using System.Text.RegularExpressions;

namespace RedCorona.Util {
    public class Command {
        public static string[] Parse(string text){
            if(text.IndexOf('"') < 0) return text.Split(' ');
            else{
                MatchCollection mc = Regex.Matches(text, "\"(?<word>[^\"]*)\" *|(?<word>\\w+)");
                int len = mc.Count;
                string[] res = new string[len];
                for(int i = 0; i < len; i++) res[i] = mc[i].Groups["word"].Value;
                return res;
            }
        }
    }
}


I'm not sure if MatchCollection implements IEnumerable<string> and therefore whether you could do a one-liner as you have done there; this code comes from pre-generic days (which is why it returns an array not a List<string>). My simple brain can only think in terms of the matched groups not the delimiters so this regex matches a quoted (first part) or unquoted (second part) 'word'.
QuestionCompiling x86 - x64 Pin
V.14-Nov-11 22:07
professionalV.14-Nov-11 22:07 
GeneralRe: Compiling x86 - x64 Pin
harold aptroot14-Nov-11 22:45
harold aptroot14-Nov-11 22:45 
GeneralRe: Compiling x86 - x64 Pin
V.14-Nov-11 22:57
professionalV.14-Nov-11 22:57 
GeneralRe: Compiling x86 - x64 Pin
Pete O'Hanlon14-Nov-11 23:04
mvePete O'Hanlon14-Nov-11 23:04 
GeneralRe: Compiling x86 - x64 Pin
V.14-Nov-11 23:21
professionalV.14-Nov-11 23:21 
GeneralRe: Compiling x86 - x64 Pin
harold aptroot14-Nov-11 23:07
harold aptroot14-Nov-11 23:07 
GeneralRe: Compiling x86 - x64 Pin
V.14-Nov-11 23:24
professionalV.14-Nov-11 23:24 
GeneralRe: Compiling x86 - x64 Pin
harold aptroot15-Nov-11 0:19
harold aptroot15-Nov-11 0:19 
GeneralRe: Compiling x86 - x64 Pin
V.15-Nov-11 0:37
professionalV.15-Nov-11 0:37 
QuestionPage Navigation Pin
pravin_mun14-Nov-11 18:43
pravin_mun14-Nov-11 18:43 
AnswerRe: Page Navigation Pin
Hum Dum14-Nov-11 19:28
Hum Dum14-Nov-11 19:28 
GeneralRe: Page Navigation Pin
pravin_mun14-Nov-11 19:50
pravin_mun14-Nov-11 19:50 
AnswerRe: Page Navigation Pin
Łukasz Nowakowski15-Nov-11 3:06
Łukasz Nowakowski15-Nov-11 3:06 
QuestionPassing Generic List<> to other forms Pin
Kendall Bodkin14-Nov-11 13:36
Kendall Bodkin14-Nov-11 13:36 
AnswerRe: Passing Generic List to other forms Pin
Luc Pattyn14-Nov-11 16:07
sitebuilderLuc Pattyn14-Nov-11 16:07 
GeneralRe: Passing Generic List to other forms Pin
Kendall Bodkin14-Nov-11 16:54
Kendall Bodkin14-Nov-11 16:54 
AnswerRe: Passing Generic List to other forms Pin
Luc Pattyn14-Nov-11 17:51
sitebuilderLuc Pattyn14-Nov-11 17:51 

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.