[Haskell-cafe] Re: wanted: haskell one-liners (in the perl sense of
one-liners)
Thomas Hartman
tphyahoo at gmail.com
Wed Mar 7 09:32:24 EST 2007
Just noticed a comment in
http://www.serpentine.com/blog/2007/02/27/a-haskell-regular-expression-tutorial/
which says there's no perl-like regex replace in the library, and links to
http://hpaste.org/697
which is an attempt at providing one.
Not sure if this is useful or not.
2007/3/7, Thomas Hartman <tphyahoo at gmail.com>:
> Okay, so much for PCRE match.
>
> Can someone show me give me pointers on PCRE replace?
>
> Ideal would be something with all the =~ s/// semantics from perl.
> (Not sure if this is included in Text.Regex.PCRE. is it?)
>
> In other words, how to do this with (preferrably) Text.Regex.PCRE ?
>
> Of course in this case a POSIX regex is fine, but since PCRE is faster
> and more expressive, and what I'm used to anyway, PCRE is probably is
> what I will tend to use by default, unless portability is paramount.
>
> ****************************
> thartman at linodewhyou:~/learning/haskell/UnixTools$ cat lines.txt
> a b c
> a b c
> a b c
>
> thartman at linodewhyou:~/learning/haskell/UnixTools$ cat lines.txt |
> perl -ne '$_ =~ s/(\w) (\w) (\w)/$1 z $3/; print $_'
> a z c
> a z c
> a z c
> thartman at linodewhyou:~/learning/haskell/UnixTools$
>
More information about the Haskell-Cafe
mailing list