GRegex in GLib

This morning I committed GRegex to svn, so glib 2.14 will have regular expression support. GRegex is a wrapper around the PCRE library by Philip Hazel that has several interesting features:

GRegex has a nice GLib-ish API that wraps PCRE functions and adds other features:

Information and Links

Join the fray by commenting, tracking what others have to say, or linking to it from your blog.

Other Posts

Reader Comments

GLib lacks a good priority queue (heap queue) implementation. There are many areas where this would be a big benefit, especially since this would allow the implementation of a better scalabale main loop implementation that behaves better with large numbers of time events. Right now the GLib main loop is rather difficult to use efficiently if you have lots of time events.

Neat, I guess. But it’s hard to get excited about regexps in GLib, since everybody I know doing serious GNOME programming is using a high-level language that already has regexps.

Also, it’s a bit of a downer to see PCRE right after reading about how much better the Thompson algorithm is (

But if there’s demand for this, then it’s a worthwhile addition, so cheers.

@me-guy: take a look at asyncworker (it’s in GNOME’s Subversion).

@ken: then you don’t know everybody :-)

Has GRegex the ability to replace a value with the output of a function that receives the matched pattern as parameter? like transform the matched result to uppercase like you see in this example in php:

Sorry, but I fail to understand how your comment relates to GRegex %-)

Most of the code in GNOME is written in C and not in high-level languages, at least gnumeric, libvte, anjuta and gtksourceview are currently using PCRE or GNU regexp. There are other programs such as gnome-system-monitor that would like to use PCRE but they can’t because it’s not a blessed dependency.

BTW the Thompson algorithm is so fast for pathological cases but it makes hard to support things like Unicode, backreferences, zero-width assertions, etc.

Yes, but it can’t be a one-liner, it’s C not PHP :)

pvanhoof: Guilty as charged. :-(

The bright side is that if a bunch of programs use GRegex, then it would be possible to write a Thompson implementation and just plug it in! :-)