Click here to Skip to main content
15,922,512 members
Home / Discussions / C#
   

C#

 
QuestionApproximation Taylor and Furie series with neuro network Pin
elinehsani22-Dec-10 0:12
elinehsani22-Dec-10 0:12 
AnswerRe: Approximation Taylor and Furie series with neuro network Pin
phil.o22-Dec-10 0:23
professionalphil.o22-Dec-10 0:23 
AnswerRe: Approximation Taylor and Furie series with neuro network Pin
Pete O'Hanlon22-Dec-10 0:25
mvePete O'Hanlon22-Dec-10 0:25 
GeneralRe: Approximation Taylor and Furie series with neuro network Pin
OriginalGriff22-Dec-10 0:45
mveOriginalGriff22-Dec-10 0:45 
GeneralRe: Approximation Taylor and Furie series with neuro network Pin
Pete O'Hanlon22-Dec-10 3:14
mvePete O'Hanlon22-Dec-10 3:14 
GeneralRe: Approximation Taylor and Furie series with neuro network Pin
musefan22-Dec-10 4:09
musefan22-Dec-10 4:09 
AnswerRe: Approximation Taylor and Furie series with neuro network Pin
Keith Barrow22-Dec-10 3:28
professionalKeith Barrow22-Dec-10 3:28 
AnswerRe: Approximation Taylor and Furie series with neuro network Pin
musefan22-Dec-10 4:15
musefan22-Dec-10 4:15 
AnswerRe: Approximation Taylor and Furie series with neuro network Pin
Alan Balkany22-Dec-10 4:28
Alan Balkany22-Dec-10 4:28 
Questiondatagridview checkbox problem [modified] Pin
Varun Sareen21-Dec-10 18:46
Varun Sareen21-Dec-10 18:46 
AnswerRe: datagridview checkbox problem Pin
Hiren solanki21-Dec-10 19:56
Hiren solanki21-Dec-10 19:56 
GeneralRe: datagridview checkbox problem [modified] Pin
Varun Sareen21-Dec-10 20:09
Varun Sareen21-Dec-10 20:09 
AnswerRe: datagridview checkbox problem Pin
GenJerDan22-Dec-10 11:25
GenJerDan22-Dec-10 11:25 
QuestionStyle vs Performance Pin
Roger Wright21-Dec-10 17:50
professionalRoger Wright21-Dec-10 17:50 
AnswerRe: Style vs Performance Pin
PIEBALDconsult21-Dec-10 17:58
mvePIEBALDconsult21-Dec-10 17:58 
GeneralRe: Style vs Performance Pin
Roger Wright21-Dec-10 18:09
professionalRoger Wright21-Dec-10 18:09 
GeneralRe: Style vs Performance Pin
PIEBALDconsult22-Dec-10 3:31
mvePIEBALDconsult22-Dec-10 3:31 
GeneralRe: Style vs Performance Pin
Roger Wright22-Dec-10 4:01
professionalRoger Wright22-Dec-10 4:01 
GeneralRe: Style vs Performance Pin
PIEBALDconsult22-Dec-10 14:28
mvePIEBALDconsult22-Dec-10 14:28 
GeneralRe: Style vs Performance Pin
Roger Wright22-Dec-10 14:39
professionalRoger Wright22-Dec-10 14:39 
AnswerRe: Style vs Performance Pin
Luc Pattyn21-Dec-10 18:25
sitebuilderLuc Pattyn21-Dec-10 18:25 
AnswerRe: Style vs Performance Pin
Pete O'Hanlon21-Dec-10 22:28
mvePete O'Hanlon21-Dec-10 22:28 
Well, for a start, if you want to continue using this, make Classify static. There's no real reason for it to be an instance method. Then, I would consider creating a Dictionary of the patterns. You could rewrite this as:
C#
private enum DataMatches
{
  Header = 0,
  Blank = 1,
  Total = 2,
  Sum = 3,
  NewData = 4,
  Data = 5,
  Unmatched = 99
}
        
private static void SetupRegex()
{
  if (dataPatterns != null && dataPatterns.Count > 0) return;

  dataPatterns = new Dictionary<string, DataMatches>();
  dataPatterns.Add(@"^(D|""D|T|S|I|E|""Z)", DataMatches.Header);
  dataPatterns.Add(@"^$", DataMatches.Blank);
  dataPatterns.Add(@"^""To", DataMatches.Total);
  dataPatterns.Add(@"^""\d\d/\d\d/\d\d\d\d"","""",", DataMatches.Sum);
  dataPatterns.Add(@"^""\d\d/\d\d/\d\d\d\d"",", DataMatches.NewData);
  dataPatterns.Add(@"^"""",""\w", DataMatches.Data);
}

private static DataMatches Classify(string s)
{
  SetupRegex();
  foreach (KeyValuePair<string, DataMatches> kvp in dataPatterns)
  {
    if (Regex.IsMatch(kvp.Key)) return kvp.Value;
  }
  return DataMatches.Unmatched;
}

I'm not a stalker, I just know things. Oh by the way, you're out of milk.

Forgive your enemies - it messes with their heads


My blog | My articles | MoXAML PowerToys | Onyx


GeneralRe: Style vs Performance Pin
PIEBALDconsult22-Dec-10 3:09
mvePIEBALDconsult22-Dec-10 3:09 
AnswerRe: Style vs Performance Pin
Keith Barrow21-Dec-10 22:56
professionalKeith Barrow21-Dec-10 22:56 
GeneralRe: Style vs Performance Pin
PIEBALDconsult22-Dec-10 3:19
mvePIEBALDconsult22-Dec-10 3:19 

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.