uCalc API Version: 5.7.0-preview.1 Released: 7/30/2026

Warning

uCalc API Preview Release Notice:This preview documentation describes the intended behavior of the API. It is not fully accurate or complete.The current preview build contains incomplete features, unoptimized performance, and is subject to breaking changes.Use of the preview version in your production code is not recommended.

{@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.

ID: 888

See: {@sq}
				
					using uCalcSoftware;

var uc = new uCalc();
var t = new uCalc.Transformer();
t.FromTo("{@sq}", """
"
""");

Console.WriteLine(t.Transform("print 'Hello'"));
				
			
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;
}
				
			
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
				
			
print "Hello"
(Real World: SQL-style Escaping) Doubling up single quotes to escape them for a SQL query.

ID: 901

See: {@sq}
				
					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
				
					#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;
}
				
			
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
				
			
It''s a trap
(Mixed Delimiter Check) Verifying that `{@sq}` captures only single quotes (ignoring double quotes).

ID: 902

				
					using uCalcSoftware;

var uc = new uCalc();
var t = new uCalc.Transformer();
t.FromTo("{@sq}", "$");

// Only the single quote should be replaced
Console.WriteLine(t.Transform("""
"Hello" and 'World'
"""));
				
			
"Hello" and $World$
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   uCalc::Transformer t;
   t.FromTo("{@sq}", "$");

   // Only the single quote should be replaced
   cout << t.Transform(R"("Hello" and 'World')") << endl;
}
				
			
"Hello" 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}", "$")
      
      '// Only the single quote should be replaced
      Console.WriteLine(t.Transform("""Hello"" and 'World'"))
   End Sub
End Module
				
			
"Hello" and $World$