JavaScript (ES2026) reference · String Methods
JavaScript String.raw() Method
A template-literal tag that returns the raw string, with backslash sequences left as written. Handy for regexes and Windows paths.
JavaScript (ES2026) Since ES2015
Syntax
String.raw`template`
Parameters
| Parameter | Description |
|---|---|
template |
A template literal; ${} substitutions still work. |
Return value
A string.
Examples
console.log(String.raw`C:\new\table`);
console.log(`C:\\new`);
Output
C:\new\table C:\new
const word = "camel";
console.log(String.raw`\b${word}\b`);
Output
\bcamel\b
Version history
| Version | Change |
|---|---|
| JavaScript ES2015 | Added |
Related
string.replace()· Replace the first match of a string or regex (every match with the g flag) with new text or a function's result.string.split()· Split a string into an array of substrings at each separator (a string or regex), with an optional limit.- JavaScript Strings · tutorial
- JavaScript String Methods · tutorial