[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: pattern matching strings with regexes

On Mon, Mar 19, 2012 at 09:20:07PM +0000, Richard Mortier wrote:
> i'm getting the vibe off the interwebs that the answer is "no" but i'll
> ask anyway - is there a standard way to do this in ocaml?  something to
> the effect of
> match s with | "[hH]ello world!+" -> do_hello
> ...etc. hopefully you get the idea :)
> would be quite helpful if writing eg., webapps.
> if not, anyone any experience with http://mjambon.com/micmatch.html
> (reference manual at http://mjambon.com/mikmatch-manual.html) which
> looks like it does roughly what i'm talking about...
> (anil- don't worry, i don't intend to take another syntax extension
> dependency in at this stage, i'm just asking :) 

I've just taken a look at Mikmatch, and it looks pretty straightforward to
add an ocaml-re (pure OCaml) version of the extension, and very useful at
that.  It's not on the critical path, so likely sometime in May, but on my
todo list now.

Right now, it has a Str and Pcre backend, both of which are supported by
ocaml-re (as well as globbing and other styles).  We can't really depend
on ocaml-pcre due to all the C dependencies of course.

Anil Madhavapeddy                                 http://anil.recoil.org



Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.