uCalc API Version: 2.1.3-preview.2 Released: 6/17/2026
Warning
uCalc API Preview Release Notice:The documentation describes the intended behavior of the API. The current preview build contains incomplete features, unoptimized performance, and is subject to breaking changes.
{@sq}
Product:
Class:
Remarks
Description: A shortcut directive that matches the single-quote character ' (specifically the _Token_QuoteChar_Single token).
The {@sq} directive is used within a uCalc::Transformer as a specialized matcher for the single-quote character. It functions as a structural anchor, allowing you to target the delimiter itself rather than the string content.
Structural Role
Like {@dq} (Topic 827), this directive matches only the single-character delimiter. It is essential for patterns where you need to manipulate the "wrapper" of a literal without necessarily affecting the data inside.
- Internal Shortcut: This is a direct call to
{@Token(_Token_QuoteChar_Single)}. - Precision Matching: Use
{@sq}to match the quote mark; use{@sqs}(Topic 832) to match a complete single-quoted string literal. Use {@QuoteChar} to match either the single or double quote character.
Inverse Matching with !
The universal inversion operator ! applies to this directive:
{@sq}: Matches the single-quote character.{!sq}: Matches any token that is not a single-quote character.
Examples
Converting single-quoted strings to double-quoted ones by targeting the delimiters.
using uCalcSoftware;
var uc = new uCalc();
var t = new uCalc.Transformer();
t.FromTo("{@sq}", """
"
""");
Console.WriteLine(t.Transform("print 'Hello'"));
print "Hello" using uCalcSoftware; var uc = new uCalc(); var t = new uCalc.Transformer(); t.FromTo("{@sq}", """ " """); Console.WriteLine(t.Transform("print 'Hello'"));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
uCalc::Transformer t;
t.FromTo("{@sq}", R"(")");
cout << t.Transform("print 'Hello'") << endl;
}
print "Hello" #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; uCalc::Transformer t; t.FromTo("{@sq}", R"(")"); cout << t.Transform("print 'Hello'") << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t As New uCalc.Transformer()
t.FromTo("{@sq}", """")
Console.WriteLine(t.Transform("print 'Hello'"))
End Sub
End Module
print "Hello" Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t As New uCalc.Transformer() t.FromTo("{@sq}", """") Console.WriteLine(t.Transform("print 'Hello'")) End Sub End Module
(Real World: SQL-style Escaping) Doubling up single quotes to escape them for a SQL query.
using uCalcSoftware;
var uc = new uCalc();
var t = new uCalc.Transformer();
t.FromTo("{@sq}", "''");
string input = "It's a trap";
Console.WriteLine(t.Transform(input));
It''s a trap using uCalcSoftware; var uc = new uCalc(); var t = new uCalc.Transformer(); t.FromTo("{@sq}", "''"); string input = "It's a trap"; Console.WriteLine(t.Transform(input));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
uCalc::Transformer t;
t.FromTo("{@sq}", "''");
string input = "It's a trap";
cout << t.Transform(input) << endl;
}
It''s a trap #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; uCalc::Transformer t; t.FromTo("{@sq}", "''"); string input = "It's a trap"; cout << t.Transform(input) << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t As New uCalc.Transformer()
t.FromTo("{@sq}", "''")
Dim input As String = "It's a trap"
Console.WriteLine(t.Transform(input))
End Sub
End Module
It''s a trap Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t As New uCalc.Transformer() t.FromTo("{@sq}", "''") Dim input As String = "It's a trap" Console.WriteLine(t.Transform(input)) End Sub End Module
(Mixed Delimiter Check) Verifying that `{@sq}` ignores double quotes.
using uCalcSoftware;
var uc = new uCalc();
var t = new uCalc.Transformer();
t.FromTo("{@sq}", "S");
// Only the single quote should be replaced
Console.WriteLine(t.Transform("""
'Hello' and "World"
"""));
SHelloS and "World" using uCalcSoftware; var uc = new uCalc(); var t = new uCalc.Transformer(); t.FromTo("{@sq}", "S"); // Only the single quote should be replaced Console.WriteLine(t.Transform(""" 'Hello' and "World" """));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
uCalc::Transformer t;
t.FromTo("{@sq}", "S");
// Only the single quote should be replaced
cout << t.Transform(R"('Hello' and "World")") << endl;
}
SHelloS and "World" #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; uCalc::Transformer t; t.FromTo("{@sq}", "S"); // Only the single quote should be replaced cout << t.Transform(R"('Hello' and "World")") << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t As New uCalc.Transformer()
t.FromTo("{@sq}", "S")
'// Only the single quote should be replaced
Console.WriteLine(t.Transform("'Hello' and ""World"""))
End Sub
End Module
SHelloS and "World" Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t As New uCalc.Transformer() t.FromTo("{@sq}", "S") '// Only the single quote should be replaced Console.WriteLine(t.Transform("'Hello' and ""World""")) End Sub End Module