using uCalcSoftware; var uc = new uCalc(); // Using {@Whitespace} to Count Indentation // A common use case for parsing structured text (like Python or YAML) // is capturing the exact whitespace at the start of a line. uc.DefineVariable("IndentLen"); var t = uc.NewTransformer(); t.Text = " Item 1"; // Indented by 4 spaces // Capture the leading whitespace into 'w' and evaluate its length t.FromTo("{@Whitespace:w} Item {id}", "<{@Self}>{@Exec: IndentLen = Length(w)}"); t.Transform(); // We can now analyze the captured whitespace Console.WriteLine($"Indentation length: {uc.EvalStr("IndentLen")}");