[Haskell-cafe] Using regexps to filter data

michael rice nowgate at yahoo.com
Mon Mar 15 10:32:28 EDT 2010

Found this tutorial: http://www.serpentine.com/blog/2007/02/27/a-haskell-regular-expression-tutorial/

Seems to work for what I need to do.



[michael at localhost ~]$ ghci
GHCi, version 6.10.4: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.
Prelude> :mod +Text.Regex.Posix
Prelude Text.Regex.Posix> "bar" =~ "(foo|bar)" :: Bool
Loading package syb ... linking ... done.
Loading package array- ... linking ... done.
Loading package bytestring- ... linking ... done.
Loading package regex-base- ... linking ... done.
Loading package regex-posix- ... linking ... done.
Prelude Text.Regex.Posix> "-123" =~ "\-?[0-9]+" :: Bool

    lexical error in string/character literal at character '?'
Prelude Text.Regex.Posix> "-123" =~ "[+-]?[0-9]+" :: Bool
Prelude Text.Regex.Posix> "+123" =~ "[+-]?[0-9]+" :: Bool
Prelude Text.Regex.Posix> "abc" =~ "[+-]?[0-9]+" :: Bool 
Prelude Text.Regex.Posix> 

--- On Mon, 3/15/10, Stephen Tetley <stephen.tetley at gmail.com> wrote:

From: Stephen Tetley <stephen.tetley at gmail.com>
Subject: Re: [Haskell-cafe] Using regexps to filter data
To: "michael rice" <nowgate at yahoo.com>
Cc: haskell-cafe at haskell.org
Date: Monday, March 15, 2010, 10:09 AM

On 15 March 2010 14:02, michael rice <nowgate at yahoo.com> wrote:
> Thanks. Looks kind of complicated. Are there any examples of how to use this stuff?

Hi Michael

I'm note sure, I haven't used the Regex package since it was moved out
of the libs distributed with GHC. I think the multiple backends were
added after this, and it was extended so matching could work on
ByteStrings as well as Strings.

PCRE-light is a simpler alternative, if you can live with PCRE style
regexs rather than Posix ones:


Best wishes


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100315/9e316de1/attachment.html

More information about the Haskell-Cafe mailing list