[Haskell-beginners] subRegex https? with anchor href tags
Daniel Fischer
daniel.is.fischer at googlemail.com
Sat Nov 12 16:29:24 CET 2011
On Saturday 12 November 2011, 16:10:58, Shakthi Kannan wrote:
> Hi,
>
> --- On Sat, Nov 12, 2011 at 8:20 PM, Daniel Fischer
>
> <daniel.is.fischer at googlemail.com> wrote:
> | Prelude Text.Regex> subRegex (mkRegex "https?[^[:space:]]+") "The best
> | is http://haskell.org\n" "<a href=\"\\0\">there</a>"
> | "The best is <a href=\"http://haskell.org\">there</a>\n"
>
> \--
>
> Is there any way we can escape the " within <a href></a>, and not get
> the \" in the output?
The \" are just because that's Haskell's way of showing Strings. Strings
are shown enclosed in quotes, and quotes (and other characters) appearing
in the String are escaped. You can see what would get written to the file
by outputting the String with putStrLn,
Prelude Text.Regex> putStrLn $ subRegex (mkRegex "https?://([:alpha:]|
[0-9]|.[[:alpha:]0-9])+") "The best is http://haskell.org." "<a
href=\"\\0\">there</a>"
The best is <a href="http://haskell.org">there</a>.
See, just like it should be.
> I am producing HTML in the output, and the \"
> doesn't work with the anchor tag. Expected output is:
>
> "The best is <a href="http://haskell.org">there</a>\n"
>
> Thanks for your prompt help!
>
> SK
More information about the Beginners
mailing list