let ans = stringConcat ["<a href=","\"",str,"\"",">",strr,"</a>"]
putStr ("\nOutput :" ++show (ans))
when I print this answer is Output :"<a href=\"www.test.com\">testing</a>"
I want to know why the extra \ is printing. \" suppose to be the escape code for double quotes. yet again it prints both \". I want to know why this happening and is there any way to put a " is side a string..?
concat function
stringConcat::[String]->String
stringConcat xs= concat xs
Don't show a String.
let ans = stringConcat ["<a href=","\"",str,"\"",">",strr,"</a>"]
putStr ("\nOutput :" ++ ans)
Also, what is stringConcat?
Yes, \" is the correct escape code for double quotes, so the string ans contains the double quotes as you expected.
The problem is that you're then using show, which is a function for showing values like they would appear in Haskell code, which means that strings with double quotes in them have to be escaped.
> putStrLn (show "I said \"hello\".")
"I said \"hello\"."
So if you don't want that, just don't use show:
> putStrLn "I said \"hello\"."
I said "hello".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With