Re: Ann: regex pack

Michael Hendricks <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <CAFHuXuYeJ+-UWOwq12Li3h1wr6riSaiqTUhjFPkPHc-1VfVKpQ@mail.gmail.com>
I've released a new version of the regex pack.  The main goal was to
support capturing parens.  Full changes:

  * Implement numbered captures for regex/4
  * Implement named captures for regex/4
  * Temporarily drop support for ^ pattern
  * Fix various regular expression mistakes



-- 
Michael


On Fri, Sep 13, 2013 at 1:49 PM, Michael Hendricks <[email protected]>wrote:

> I love DCGs as much as the next Prolog fan, but sometimes a tiny regular
> expression will do the job.  Or perhaps regular expressions are part of
> your app's UI.  Anyway, this pack<http://www.swi-prolog.org/pack/list?p=regex>supports many features of Perl compatible regex (see link for full support).
>
> As the semantic version number indicates, the API is very early and will
> probably change. It currently uses =~ (as do Haskell and Perl), but that
> gives no access to captured values.  A YAP-compatible API would support
> captures so I might do that.  I'd also love to use
> prolog_load_context(variable_names, _) with regex named captures to
> automatically bind clause variables by name.
>
> I considered supporting quasiquotation (so one doesn't have to escape all
> the slashes), but decided for now that a regex that complex should probably
> be rewritten as a DCG anyway.
>
> The regular expression engine is currently a naive interpreter.  I partly
> did that so that I have an interpreter to play with as I experiment with
> some partial evaluation ideas.  It would be cool to partially evaluate the
> regex interpreter against a regex to generate fast, concise Prolog code.
>
> Last thought: I tried to design the library to support pluggable regex
> engines.  The idea is that one just adds a single line:
>
>     :- use_module(library(regex/engine/re2)).
>
> and your regular expressions are now handled by the re2 engine<https://code.google.com/p/re2/> (or
> PCRE or POSIX or ...).  Any interest in such things?  I've used similar
> tools to good effect in both Haskell and Perl.
>
> --
> Michael
>
-------------- next part --------------
HTML attachment scrubbed and removed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.