MatchCollection.Matches() Hangs when attempting to access data member

  • Thread starter Thread starter David Elliott
  • Start date Start date
D

David Elliott

I am having a problem with a specific scenario with regular expressions. I am doing
some document processing and am looking for date formats within a document.

When I try to access the a property such as Count, after using Regex.Matches(),
the application hangs for several minutes, at which time it picks up and continues.
This is unfortunately causing severe performance issues for the rest of the server.

I have included a working console application which is included below. The byte
array is the data that I was given to be processed. If you look at it, once it is a string,
you will see that it is actually copyright, trademarks, etc. As the data comes to me
via automation, I can not validate it before hand.

As I stated before, I am looking for dates. Given the input data, I would expect to
see NO results. At worst, an exception thrown, but NOT hanging the system.

Any help is appreciated.

If you have any questions, please feel free to contact me for more information.

Cheers,
Dave



===========================


using System;
using System.IO;
using System.Text;
using System.Collections;
using System.Text.RegularExpressions;


namespace regex
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
Regex rx;
MatchCollection mc;
string inText;
string exPattern;
int count;

byte[] data =
{
0xff,0xfe,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,
0x20,0x00,0x22,0x21,0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0x22,0x21,0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xa9,0x00,
0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,
0x20,0x00,0x22,0x21,0x20,0x00,0xa9,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xa9,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0x22,0x21,0x20,0x00,0xae,0x00,0x20,0x00,0x22,0x21,0x20,0x00,0xa9,0x00,
0x20,0x00,0x22,0x21,0x20,0x00,0x22,0x21,0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0x22,0x21,0x20,0x00,0xa9,0x00,0x20,0x00,0x22,0x21,
0x20,0x00,0x22,0x21,0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0x22,0x21,0x20,0x00,0xae,0x00,0x20,0x00,0x22,0x21,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0x22,0x21,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0x22,0x21,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0x22,0x21,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xa9,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0x22,0x21,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,
0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xa9,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xa9,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0x22,0x21,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xa9,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,
0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0x22,0x21,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0x22,0x21,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0x22,0x21,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0x22,0x21,
0x20,0x00,0xae,0x00,0x20,0x00,0x22,0x21,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0x22,0x21,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,
0x20,0x00,0x22,0x21,0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,
0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0x22,0x21,0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0x22,0x21,
0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0x22,0x21,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xa9,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xa9,0x00,
0x20,0x00,0xa9,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xa9,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xa9,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xa9,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xa9,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0x22,0x21,0x20,0x00,0x22,0x21,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xa9,0x00,0x20,0x00,0x22,0x21,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xa9,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0x22,0x21,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0x22,0x21,0x20,0x00,0xae,0x00,
0x20,0x00,0xa9,0x00,0x20,0x00,0x22,0x21,0x20,0x00,0xae,0x00,0x20,0x00,0x22,0x21,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0x22,0x21,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0xa9,0x00,0x20,0x00,0xae,0x00,0x20,0x00,0xae,0x00,
0x20,0x00,0xae,0x00,0x20,0x00,0x22,0x21,0x20,0x00,0xae,0x00,0x20,0x00,0x0d,0x00,
0x0a,0x00,0x20,0x00,0x0d,0x00,0x0a,0x00,0x0d,0x00,0x0a,0x00
};

inText = Encoding.Unicode.GetString(data);

count = 0;
exPattern = @"(\D+[\.]* +\D* *\d+ *,0x *\d+)";

Console.Out.WriteLine("Starting...");
try
{
// Create Regular Expression
rx = new Regex(exPattern);

// Perform the Regex Match
mc = null;
mc = rx.Matches(inText);
if (mc != null)
{
count += mc.Count;
Console.Out.WriteLine("Number of matches found: " + count.ToString());
}

Console.Out.WriteLine("Regular Expressions are done");
}
catch (Exception ex)
{
string s = ex.Message;
s = null;
}

System.Console.Out.WriteLine("Matches: " + count.ToString());
}
}
}
 
Hi David,

It seems that the regular expression is somewhat complicated which takes
the regex a long time to do the search.
You may try to the do the match instead of the matches operation which
caused the same behavior.
Match mt = rx.Match(inText);//The line will continue for a long time.

If you are looking for a date as the format below.
inText="06/04/04";
You may try to the pattern as below.
exPattern = @"(\d{2}[\./]{1}\d{2}[\./]{1}\d{2})";

Can you tell me what kind of pattern you are going to match so that we can
figure out another pattern for it?

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top