Click here to Skip to main content
11,929,675 members (50,029 online)
Click here to Skip to main content


62 bookmarked

Henry Spencer's Regexp Engine Revisited

, 2 Jul 2003
A small, Unicode-aware regular expression engine based on Henry Spencer's early work
/* invisible customization header for regexp implementation */

#include <stdlib.h>
#include <string.h>

#ifdef __cplusplus
extern "C"

/* undefine this to remove some extra checks */
/* internal error handler -- you need to provide an implementation.
 * By default, this does nothing, but you may want to send stuff to
 * the debug log or something. */
void re_report(const char* error);

/* memory allocation routines. Those are defaulted to
 * the C heap management routines. */
void* re_malloc(size_t sz);
void  re_cfree(void* p);

/* unicode handlers for translating stuff.  Provide a sane implementation
 * for your character set.  A default implementation is provided and
 * it kind of sucks.
 * If REGEXP_UNICODE is not defined, those functions won't be used. */
CHAR_TYPE* re_ansi_to_unicode(const char* s);
char* re_unicode_to_ansi(const CHAR_TYPE* s);

#ifdef __cplusplus

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Web Developer
Canada Canada
I'm a senior software developer, working at Silanis Technology ( I've acquired quite a bit of experience (usually the hard way!) in Win32 and raw COM programming on the job. In my spare time, I like to monkey around with POSIX code.

I'm mostly interested in portable C++ libraries. I'm happiest when I develop portable C++ code--C++ being such a powerful language as long as one keeps clear of the rather nasty subtleties of the language.

I hope the articles I contribute will be of some help to someone. If even one person gains a few hours through use of that code, I'll be very happy.

When not coding, I like to listen to Anime and try to learn Japanese. It's not working too well so far, unfortunately. :{)

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.151126.1 | Last Updated 3 Jul 2003
Article Copyright 2003 by Sunspot
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid