2009-03-08: Fixed build problem on Mac OS X with macports.
Thanks to Ralph Douglass <email@example.com> for the
2008-05-06: Fixed build problem with newer versions of PCRE.
2008-03-14: Synced with Jane Street tree.
2008-01-25: Added new function:
This function returns the names of all named substrings in a
Thanks to Benedikt Grundmann <firstname.lastname@example.org>
for the patch!
2007-07-12: Improved build scripts for Windows.
Thanks to Christophe Troestler
<Christophe.Troestler@umh.ac.be> for the patch!
2007-07-12: Improved documentation for Win32 builds, and added some build
scripts usable on Windows.
Thanks to Christophe Troestler
<Christophe.Troestler@umh.ac.be> for this contribution!
2007-04-23: callback_exn -> caml_callback_exn.
2006-11-22: Updated OCamlMakefile.
2006-06-11: Updated to pcre-5.0!
New representation for callbacks: they now take only one
argument (a record of the callback data).
Added partial matching and auto callouts.
2006-01-16: Updated OCamlMakefile.
Removed a superfluous binding.
2005-08-18: Fixed a small compilation problem on rare platforms by
2005-06-08: Relaxed license. Fixed copyright headers.
2005-05-31: Fixed some uncleanliness reported by Saffire (FFI-type checker).
2004-09-17: Fixed a bug concerning null patterns in exec_all (extract_all
and extract_all_opt are also affected).
2004-05-19: Updated Makefile.mingw.
Thanks to Jeff Henrikson <email@example.com> for the patch!
2004-04-29: Changed behaviour of "get_substring"!!!
It now does not return the empty string anymore if an
accessed substring was not captured. It raises the exception
Three new functions:
These behave like the functions without "opt", but return
"Some substring" if a substring was captured, and "None"
2004-04-27: Updated OCamlMakefile.
2004-04-24: Updated OCamlMakefile.
2004-03-28: Changed interface to build-time configuration functions
2004-02-21: Added CAMLprim in the C-interface where appropriate.
2004-02-08: Fixed a minor bug concerning returning unit values from C.
2004-01-31: Added pcre_make.win32/Makefile.mingw. Thanks to Jeffrey
Henrikson <JEFHEN@SAFECO.com> for this contribution!
2004-01-13: Updated pcre_make.win32/pcre.h.
2003-12-30: Fixed documentation.
2003-12-21: Updated to pcre-4.5!
2003-12-19: Fixed a small (but probably unnoticable) bug concerning
allocation of optional values in the C-stubs.
2003-12-12: Updated OCamlMakefile. Renamed stubs (invisible to users).
2003-11-16: Updated pcre_make.win32/pcre.h to reflect newest PCRE-version.
May help Windows users.
2003-10-08: Upgraded to pcre-4.4!
New flag for compiling patterns: NO_UTF8_CHECK
New exception: BadUTF8
2003-09-30: Fixed a bug in the documentation.
2003-06-17: Fixed a bug in the documentation.
2003-05-29: Updated to pcre-4.3!
Major change: callouts are now fully supported! This allows
the matching engine call OCaml-code while matching - quite
powerful! Please see the interface specification for more
Many small changes (improvements) in C-code. Updated
2003-04-08: Updated OCamlMakefile. Reformatted documentation.
2003-03-20: Added new function "get_subject". Patched OCamlMakefile.
2003-03-18: Major update: upgraded to pcre-4.1!
New flag "NO_AUTO_CAPTURE".
Renamed all occurrences of "firstchar" to "firstbyte".
2003-01-07: Updated OCamlMakefile to make use of "findlib".
Added support for UTF-8 character encodings.
Better installation and documentation for Win32.
Thanks to Artem Prisyznuk <firstname.lastname@example.org> for the above
2002-12-14: Fixed a bug concerning zero-sized matches effecting
"replace", "qreplace", "substitute_substrings" and
2002-12-08: Improved documentation of "pcre_exec".
2002-11-24: Fixed a bug in "full_split" concerning matched subgroups.
2002-11-12: Added a new function "extract_all" (see interface
2002-08-16: Fixed a bug in the "split"-function:
The Perl-splitting semantics was not completely adhered to:
leading whitespace was stripped after the matching process
rather than before, which lead to incompatible behaviour
when a maximum bound was used.
Thanks to Yutaka Oiwa <email@example.com> for the
2002-07-31: Fixed a bug in the following functions:
Transformed most part of the library to make it slightly
more efficient and simple. The interface is still the same!
Updated OCamlMakefile + documentation.
2002-07-15: Fixed a mistake in the documentation.
2002-05-05: Fixed a bug with the generation of byte-code libraries that
dynamically link the PCRE.
2002-05-01: Removed C-library from distribution! Users must install it
on their own now. Reorganized whole distribution and updated
OCamlMakefile again for better support of dynamic and/or
2002-04-30: Updated OcamlMakefile: it does not ask for confirmation
during installation anymore!
2002-03-06: Upgraded to pcre-3.9. This should not change anything for
2002-03-01: Updated OcamlMakefile.
2002-02-24: Separated compilation of library and examples to prevent
confusions when the library needs to be installed before
one can build the examples.
2002-02-15: Fixed a bug in the pcre_exec-function which was introduced
ten days ago during correction of another bug (thanks to
Gerd Stolpmann for the report!).
2002-02-15: Added the option to compile the library statically only.
Updated INSTALL-notes to explain possible installation
problems associated with support of dynamic linking.
Added META-file for findlib.
2002-02-12: Rewrote interface documentation to support OCamldoc.
Fixed a portability bug with shared libraries.
2002-02-10: Removed project from Sourceforge for simpler maintainance.
2002-02-07: Important news: library is linked dynamically now by default.
2002-02-06: Fixed a stupid bug affecting the following functions
(thanks to Jacek Chrzaszcz for the bug report!):
Also done: converted literal pattern strings in the library
and the cloc-example so that the escape char (backslash) does
not cause warnings anymore with the new OCaml-release. The
latter is more paranoid about unknown escape combinations,
requiring the user to add extra backslashes.
2002-01-07: Fixed a stupid bug: the position argument (offset) was
not correctly handled in replacement and substitution
functions, leading to wrong results. As it seems, people
seldom use arguments other than zero...
The "subst"-example now assumes that offsets other than zero
should not lead to an error if it exceeds the line length.
The line is just copied instead.
2001-12-28: Added README.win32 (courtesy of John W. Small).
Updated README so that it is generated by Hevea.
2001-11-19: Upgraded to the newest release of the underlying C-library
Added a tiny patch to satisfy the Visual C++ compiler under
W2K (thanks to John W. Small!).
Updated contact address.
2001-11-17: Updated OcamlMakefile.
2001-09-15: Upgraded to the newest release of the underlying C-library
Added a new function: substitute_substrings
It is similar to "substitute", but takes the full substring
information of the match rather than the matching string.
Thanks to Patrick M. Doane for proposing this missing feature!
2001-09-07: Updated OcamlMakefile
2001-08-27: Fixed a bug in the splitting function: leading whitespace was
accidently always removed when using a regular expression
rather than a pattern. This behaviour should only happen
for the default whitespace pattern, which is used if you
do not specify any pattern or regexp in the function call.
2001-06-30: Removed "Printexc.catch" from examples: is going to be
deprecated in upcoming OCaml-release.
2001-05-22: Fixed typo in documentation.
2001-04-25: Added a new function: asplit
It is identical to "split" with the exception that it
returns a string array instead of a string list. This makes
it easier for the user to access strings by index.
Added a new option to "get_substrings" and "extract": full_match
When "full_match" is true (default: yes), then the resulting
string array will contain the full match at index 0,
otherwise the result will only contain captured substrings.
Removed superfluous comments in "pcre.ml": they are already
present in the interface documentation anyway.
2001-04-08: Small patch that makes this library compile on OpenBSD, too.
2001-01-30: Made Makefile more general (allows simpler addition of
2001-01-24: Updated OcamlMakefile: made default definition of
"OCAMLLIBPATH" backwards compatible again: some people
do not use the CVS-version of OCaml, which supports the
"-where"-option. People with the new compiler will not
notice any effect.
2001-01-06: Added a new function: exec_all
It allows you to execute pattern matching over a whole
string until no more matches can be found: then it returns
the array of all matching "substrings". You can extract
subpatterns of each of those matching substrings again with
the usual functions.
Fixed a minor inconsistency in "next_match".
2000-12-23: Updated OcamlMakefile: makes use of the new "-where"-keyword
to find the path to the standard library if it is not
2000-12-14: Pedantry in the C-interface: added "const" qualifiers.
2000-12-09: Made some functions tail-recursive (very unlikely to cause
any noticable effect for most people).
2000-12-02: Cleaned up the code a bit for distribution on SourceForge.
Speed of some operations should be very slightly improved, too.
2000-11-16: Fixed a stupid bug that could crash your programs under rare
circumstances (when you use faulty regular expressions).
Added an internally used exception (InternalError) to the
interface of the library. This allows the user to handle
the case when the C-engine exhibits undefined behaviour
(should never happen, anyway).
2000-09-27: Upgraded to the newest release of the underlying C-library
See "pcre-C/ChangeLog" for more information (mostly minor
Renamed "pgrep" to "pcregrep" to prevent name hiding on
Solaris (change as suggested in the C-library distribution).
2000-06-24: Updated OcamlMakefile
2000-06-13: Updated OcamlMakefile
2000-06-12: Mini-optimisation: lifted a pure value out of a function body.
2000-06-11: Updated OcamlMakefile
2000-06-08: Added installation routine + updated OcamlMakefile again:
This upgrade makes installation much easier! Read the
2000-06-07: Updated to new OcamlMakefile
2000-06-05: Added a new function:
get_substring_ofs substrings n
This allows you to get the offset positions of the matching
pattern and the substrings directly from a value of type
"substring". See the interface documentation for details.
2000-05-15: Upgraded to the newest release of the underlying C-library
This does not add new features, but is said to fix some
PERL-compatibility bugs and improves portability.
2000-05-04: Minor update of C-interface:
Use the new "hash_variant"-function to compute the hash value of
variants (used Callback.register before - a bit clumsy).
2000-04-24: New release: compiles with OCaml-3.00.
Lots of changes in interface! OCaml-3.00 introduced some syntax
changes for labels. Additionally, no keywords are allowed for
them. All this required quite some renamings. I tried to stick to
the new labels of the "str"-library as close as makes sense.
Sorry for this inconvenience, but I think that adhering to some
"standard" is a Good Thing...
For further information on the changes, look at the documentation
of the interface file.
2000-04-23: Minor cleanup of C-interface:
Made local functions + variables static and moved a check for
error codes (lint should be happier now).
2000-04-01: Changed linking of the library again (marginally):
The new linking semantics for byte code libraries allows passing
of flags that are remembered. This then only requires linking
executables against "pcre.cma" - the C-library ("libpcre.a") will
be linked in automatically.
2000-03-30: Cleaned up the C-interface:
Removed a possible bug in the allocation of firstchar values.
Saner handling of polymorphic variants (not hard-wired
integers anymore - registered via callbacks).
Better GC-settings: much nicer to the GC now (fewer full
cycles - hardly more memory consumption). Should make
programs run slightly faster when regular expressions are
Changed linking of the library to suit the semantics of
the upcoming OCaml-major release (backward compatible).
2000-02-07: Changed interface of function "foreach_file":
No idea why I implemented a tuple in the interface instead of a
curried function. Must have been the drugs... ;-)
val foreach_file :
string list -> (string * in_channel -> unit) -> unit
val foreach_file :
string list -> (string -> in_channel -> unit) -> unit
Additionally, this function now also closes the file channel
in case of an exception. The exception gets reraised,
2000-02-05: Eliminated a PERL-incompatibility of the "split"-function:
When neither the pattern nor the compiled regular
expression are specified, "split" defaults to a whitespace
pattern. However, PERL additionally strips leading
whitespace, but *only* when in "default" mode.
This last "feature" (?) was overseen during the introduction
of labels and default arguments.
2000-02-05: Updated the C-library to the newest release (pcre-3.0).
This is a major release, but the changes to the OCaml-part
are rather small: just the functionality concerning
information on compiled patterns has changed.
Instead of the former "info"-function, several ones are
provided. I think this is the most convenient way to handle
this, because it does not force the user to do explicit
pattern matching on results: due to the number of new
info-options this would have been rather confusing.
Because the old PCRE-function "pcre_info" is obsolete,
I chose to drop its OCaml-interface completely. I do not
think that it is an often used part, anyway.
See the interface file and the ChangeLog + documentation
of the C-library to see, what has changed in detail.
The other few changes just marginally effect efficiency. One
bug was present in the last release in the "info"-part
(polymorphic variants were not correctly represented).
This has changed anyway and should work fine now.
2000-01-10: "foreach_line" uses stdin as labeled (label: 'in') default
1999-12-29: Lots of changes:
* Uses the new features of OCaml 2.99:
Labeled parameters and default arguments for much more
convenience. E.g. write
split pos:1 "foo bar"
to get the list ["oo"; "bar"].
Polymorphic variants for passing options: this change allows,
for example, using the data constructor "ANCHORED" for both
compiling flags and at matching time instead of "C_ANCHORED"
* Got rid of all the superfluous shortcuts, like "bounded_psplit"
and the like. Labeled parameters are much more readable and
* Removed the functions compatible to the "Str"-module. It's
probably rather confusing for people to see two different kinds
* Renamed functions due to the use of labels and the removing of
the obsolete compatibility functions.
* Updated documentation with more details on using the library.
1999-12-21: Small change (2 chars...) to make the C-interface compile with
the newest release (OCaml 2.99).
1999-09-27: Fixed a bug which occurs, when replacements or substitutions
in strings are longer than the subject string itself.
This concerns functions "replace_all", "qreplace_all" and
"substitute_all" + their variants.
THANKS to GERD STOLPMANN (Gerd.Stolpmann@darmstadt.netsurf.de)
for finding another bug!
1999-09-21: Fixed some bugs in "pcre_intf.c":
"Store_field" was used inappropriately throughout the file,
which could lead to segfaults in the garbage collector. This
was corrected by using the "Field"-macro where appropriate.
Protected an input parameter from being reclaimed too early.
Initialized a field before throwing an exception to please
The GC should be happy now...
THANKS to GERD STOLPMANN (Gerd.Stolpmann@darmstadt.netsurf.de)
for the patch!
1999-08-31: Updated to pcre-2.08 - this should fix some bugs. See
"pcre-C/ChangeLog" for details.
Renamed directory "pcre-C-2.07" to "pcre-C" to allow for
Added CVS-info to sources.
1999-08-24: Updated to pcre-2.07. Splitting is 100% PERL-compatible now.
New runtime option: NOTEMPTY (see interface for details).
Two additional examples: cloc and count_hash.
New functions: sregexpo, sregexp, sregexp_case_fold.
1999-08-02: Exception handling more regular now:
Raises [Invalid_argument] instead of [Failure] where
Raises [InternalError] if C-library exhibits undefined
behaviour (has never happened so far).
1999-07-30: Bugfix in "pcre_intf.c":
"pcre_ocaml" should work now on 64-bit architectures...
1999-07-29: Small fix in "pcre_intf.c":
strict compilers (gcc is not very strict) otherwise complain
about undefined behaviour in a certain line.
Explicitely mention all include files.
Removed unused variable.
Also moved a line for efficiency...
1999-07-28: First release.