-1

I have the following string and want to replace \n with < br>

string = "Subject: [Information] \n Hi there, \n...\n\n\n\\ud83d\\ude00\n--\n"
string.gsub('\n','<br>')  #don't work

Than I tried

string.gsub("\n",'<br>')

It works, can explain this to me. String in double quotes are different from string in single quotes or it has to do with escape sequence.

Thanks

user1969191
  • 282
  • 1
  • 12

1 Answers1

0

Single quotes preserve characters like \ as-is. Double quotes interpolate them, where \n means newline-character.

There's others, many of these coming from things like C.

tadman
  • 208,517
  • 23
  • 234
  • 262