Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

C Regular Expressions Slow!

Status
Not open for further replies.

bitwise

Programmer
Mar 15, 2001
269
US
Does anyone have any idea why C regular expressions are so slow!? I had a simple regular expression:

/interest.*_/

It is a very basic reg. exp. that matches things like:

interests_
interest_
interesting_

In C using regex.h on a 4736 line file each with an occurence of "interest" it takes 1.33 seconds.

In perl it takes 0.14 seconds!

Now I don't know what to do? I need C but I need fast regular expressions! Any ideas? Does anyone know of a good mechanism for calling a perl program in C and returning a value from the perl program to the C calling program?

Or alternatively, a way to speed up C regular expressions?

Thanks,
-bitwise
 
chipperMDW is correct, there is no such thing as "C regular expressions". you must be using a library for your regular expressions and it is a poor one. therefore you need to get a better library. The only problem with chipper's post is that you won't find boost at that url, try
I'm not a Perl expert but i always thought that it was written in C, can anyone confirm that?

-pete
 
Yeah, Perl is written in C, and I am using the default regex library installed on the SunOS system I'm running this on. Unfortunately, I don't have the permissions to install a different regular expression library. Even still, it shocked me that this library sucked so much.

-bitwise
 
Whoops. Sorry about the link. I type it every day and I still can't get it right.

Boost's library shouldn't be too hard to install in your own directory. It comes with a makefile and instructions for both gcc and Sun Workshop. It claims not to require any configuration on most platforms.
 
>> . Unfortunately, I don't have the permissions to
>> install a different regular expression library.

but you do have permission to build and run your own C program? That does not make any sense.

-pete
 
This library offers you C regexp's in a perly way.
I have never tried it.

Please, lets keep our focus on C here. There is no
reason to offer solutions in C++ here when there
are two forums devoted to C++ and the solution is
not OO.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top