String.raw: Backslashes That Survive

Mrs. Endang's letter board: String.raw and a plain template side by side, one tile per character. Watch \n get processed or stay raw. An interactive…

Why it matters

Whenever a backslash is data rather than an escape (Windows paths, regex sources, LaTeX, SQL LIKE patterns), a plain template quietly changes your text without an error. String.raw fixes it with one prefix, no doubling every backslash. Two things still happen while the code is read, String.raw or not: a backslash before a backtick and before ${.

The key idea

Every piece of a template is kept twice, and String.raw takes the raw one

Common mistakes

Try it in this playground