using uCalcSoftware; var uc = new uCalc(); var t = uc.NewTransformer(); // Define a custom string literal using pipe characters `|...|`. // The regex `\|([^\|]*)\|` captures the inner content in group 1. // We set `subMatchGroup` to 1 to use this group as the token's value. var pipeStringToken = t.Tokens.Add(""" \|([^\|]*)\| """, TokenType.Literal, "", 1); // Complete the definition by setting the data type and QuotedText property. pipeStringToken.DataType = uc.DataTypeOf("String"); pipeStringToken.IsProperty(ItemIs.QuotedText, true); // Define a simple rule to prove the token works. t.FromTo("Test: {@String:s}", "Found: {s(0)} | Content: {s(1)}"); // The transformer now recognizes |...| as a string literal. Console.WriteLine(t.Transform("Test: |hello|"));