Osy#the first language built for agents
Agents firstAgentic appsWorkflowsDurable Execution — built inSecurityTestingThe editorThe UI modelOne program

Reference / Function

verbatim strings (@"…")

@"C:\logs\today.txt"

`@"…"` is a string where a backslash is just a backslash. Nothing inside is an escape, `""` writes a single quote, and the text may run across lines. Use it for regular expressions, paths, and any text where doubling every backslash would make the value harder to read than the thing it describes.

stable2 examples compiled by CIsyntaxstringliteral

Summary#

An ordinary string treats \ as the start of an escape: "\n" is a newline, "\t" a tab. That is what you want in prose and exactly what you do not want in a regular expression or a path, where a backslash is part of the value. Prefixing the string with @ turns escape processing off for the whole literal.

Signature#

@"ORD-\d{6}"            // a regular expression, written the way a regular expression is written
@"C:\logs\today.txt"    // a path, with single backslashes
@"she said ""no"""      // "" is one literal quote — the only sequence with a meaning

Description#

Inside @"…":

  • A backslash is a backslash. @"\d" is two characters. The same value written ordinarily is "\\d".
  • "" is one quote character. It is the only two-character sequence that means something else, and it exists because a lone " has to be able to end the literal.
  • A newline is allowed. The literal runs until its closing quote, so it may span lines, and the line breaks are part of the value.

Everything else about the string is unchanged — it is the same type, usable anywhere a string is.

Interpolation is a separate prefix: $"…" substitutes {Holes}. The two are not combined today; build the value with an ordinary interpolated string, or keep the pattern verbatim and interpolate around it.

Examples#

entity Shipment {
  [MaxLength(64)] string Reference;
}

app.Memory = new MemoryConfig {
  // Verbatim: the regular expression reads as a regular expression.
  Identifiers = [ @"SHP-\d{6}", @"[A-Z]{3}-\d{4}" ]
};
string PatternA() { return @"ORD-\d{6}"; }    // verbatim — one backslash
string PatternB() { return "ORD-\\d{6}"; }    // ordinary — the backslash is escaped

// Both return the six characters `ORD-\d{6}`; the first is the one you can read.

See also#

Related

format specifiers

Formats a number to a string with a .NET format specifier — F2 for two decimal places, N0 for a grouped whole number, C…

identifier patterns (app.Memory)

`app.Memory` tells search what an identifier looks like in YOUR data — an order number, a part code, an SKU. Search…