[Haskell-cafe] Re: Has anybody replicated =~ s/../../ or even something more basic for doing replacements with pcre haskell regexen?

Brandon S. Allbery KF8NH allbery at ece.cmu.edu
Sat Mar 14 19:39:11 EDT 2009


On 2009 Mar 14, at 19:01, Thomas Hartman wrote:
> FWIW, the problem I was trying to solve was deleting single newlines
> but not strings of newlines in a document. Dead simple for pcre-regex
> with lookaround. But, I think, impossible with posix regex.

s/(^|[^\n])\n($|[^\n])/\1\2/g;

POSIX regexen may be ugly, but they're capable.

-- 
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery at kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university    KF8NH


-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 195 bytes
Desc: This is a digitally signed message part
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090314/c3b7c772/PGP.bin


More information about the Haskell-Cafe mailing list