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

2009-03-17 Thread Cristiano Paris
On Fri, Mar 13, 2009 at 1:19 AM, ChrisK hask...@list.mightyreason.com wrote: At the cost of writing your own routine you get exactly what you want in a screen or less of code, see http://hackage.haskell.org/packages/archive/regex-compat/0.92/doc/html/src/Text-Regex.html#subRegex for

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

2009-03-17 Thread Thomas Hartman
2009/3/16 ChrisK hask...@list.mightyreason.com: Let me open the discussion with all the questions I can quickly ask:  What should the subRegex function do, exactly?  (Single replacement,global replacement,once per line,...) Try to do the same thing as =~ s/../../ in perl. For a version 1:

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

2009-03-16 Thread ChrisK
Thomas Hartman wrote: testPcre = ( subRegex (mkRegex (?!\n)\n(?!\n)) asdf\n \n\n\nadsf ) == asdf \n\n\nadsf quoting from the man page for regcomp: REG_NEWLINE Compile for newline-sensitive matching. By default, newline is a completely ordinary character with no special

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

2009-03-16 Thread ChrisK
Thomas Hartman wrote: testPcre = ( subRegex (mkRegex (?!\n)\n(?!\n)) asdf\n \n\n\nadsf ) == asdf \n\n\nadsf quoting from the man page for regcomp: REG_NEWLINE Compile for newline-sensitive matching. By default, newline is a completely ordinary character with no special

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

2009-03-16 Thread Thomas Hartman
Thanks, that was extremely helpful. My bad for being so sloppy reading the documentation so sloppily -- I somehow glossed over the bit that backreferences worked as one would expect. To atone for this, http://patch-tag.com/repo/haskell-learning/browse/regexStuff/pcreReplace.hs shows successful

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

2009-03-16 Thread ChrisK
Don Stewart wrote: tphyahoo: Is there something like subRegex... something like =~ s/.../.../ in perl... for haskell pcre Regexen? I mean, subRegex from Text.Regex of course: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/regex-compat Thanks for any advice, Basically, we should

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

2009-03-15 Thread Thomas Hartman
Except that there is nothing like =~ s in haskell, as far as I can tell. I was mulling over this and thinking, the nicest solution for this -- from the lens of perl evangelism anyway -- would be to have some way of accessing the perl6 language =~ s mechanism in pugs, which would get us everything

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

2009-03-14 Thread Thomas Hartman
So, I tweaked Text.Regex to have the behavior I need. http://patch-tag.com/repo/haskell-learning/browse/regexStuff/pcreReplace.hs 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

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

2009-03-14 Thread Don Stewart
Also, consider stealing the regex susbt code from: http://shootout.alioth.debian.org/u64q/benchmark.php?test=regexdnalang=ghcid=4 tphyahoo: So, I tweaked Text.Regex to have the behavior I need. http://patch-tag.com/repo/haskell-learning/browse/regexStuff/pcreReplace.hs FWIW, the

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

2009-03-14 Thread Brandon S. Allbery KF8NH
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

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

2009-03-12 Thread ChrisK
Thomas Hartman wrote: Is there something like subRegex... something like =~ s/.../.../ in perl... for haskell pcre Regexen? I mean, subRegex from Text.Regex of course: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/regex-compat Thanks for any advice, thomas. Short answer: No.