CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 17 of 17
  1. #16
    Join Date
    Sep 2004
    Posts
    1,361

    Re: Help parsing gigantic text files (64 MB+ )

    I figured it out. RegEx are slow. Period.

    I got rid of my RegEx and just used IndexOf(). Even if I need to do multiple searches on the same line to qualify / disqualify, it is MUCH faster than a single RegEx. Even simple RegEx like "MyNameIsBob" is much slower done as a RegEx vs IndexOf().

    Now that I have changed over and gotten rid of them, it is parsing this file very quickly.

    The moral is:

    Do not use a RegEx unless you absolutely have to. They are very, very slow compared to a simple string search, or even several string searches.

  2. #17
    Join Date
    Oct 2003
    Location
    .NET2.0 / VS2005 Developer
    Posts
    7,104

    Re: Help parsing gigantic text files (64 MB+ )

    Quote Originally Posted by DeepT View Post
    They are very, very slow compared to a simple string search, or even several string searches.
    You've no idea how RegEx work, it would seem. IndexOf will always be faster but much less capable.

    The moral is:
    Use the right tools for the job
    "it's a fax from your dog, Mr Dansworth. It looks like your cat" - Gary Larson...DW1: Data Walkthroughs 1.1...DW2: Data Walkthroughs 2.0...DDS: The DataSet Designer Surface...ANO: ADO.NET2 Orientation...DAN: Deeper ADO.NET...DNU...PQ

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured