WhitespaceSensitive()

ID: 142

				
					using uCalcSoftware;

var uc = new uCalc();
var t = uc.NewTransformer();
var Text = "This is a test.";
var p = t.FromTo("This {words:3}", "[{words}]");

Console.WriteLine($"Input: {Text}");
Console.WriteLine($"Pattern: {p.Pattern}");
Console.WriteLine("");

Console.WriteLine("3 captured tokens are in brackets");
Console.WriteLine("");

Console.WriteLine($"WhitespaceSensitive = {t.DefaultRuleSet.WhitespaceSensitive}");
Console.WriteLine(t.Transform(Text));
Console.WriteLine("");

t.DefaultRuleSet.WhitespaceSensitive = true;
Console.WriteLine($"WhitespaceSensitive = {t.DefaultRuleSet.WhitespaceSensitive}");
Console.WriteLine(t.Transform(Text));

				
			
Input: This is a test.
Pattern: This {words:3}

3 captured tokens are in brackets

WhitespaceSensitive = False
[is a test].

WhitespaceSensitive = True
[ is ]a test.
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

#define tf(IsTrue) ((IsTrue) ? "True" : "False")

int main() {
   uCalc uc;
   auto t = uc.NewTransformer();
   auto Text = "This is a test.";
   auto p = t.FromTo("This {words:3}", "[{words}]");

   cout << "Input: " << Text << endl;
   cout << "Pattern: " << p.Pattern() << endl;
   cout << "" << endl;

   cout << "3 captured tokens are in brackets" << endl;
   cout << "" << endl;

   cout << "WhitespaceSensitive = " << tf(t.DefaultRuleSet().WhitespaceSensitive()) << endl;
   cout << t.Transform(Text) << endl;
   cout << "" << endl;

   t.DefaultRuleSet().WhitespaceSensitive(true);
   cout << "WhitespaceSensitive = " << tf(t.DefaultRuleSet().WhitespaceSensitive()) << endl;
   cout << t.Transform(Text) << endl;

}
				
			
Input: This is a test.
Pattern: This {words:3}

3 captured tokens are in brackets

WhitespaceSensitive = False
[is a test].

WhitespaceSensitive = True
[ is ]a test.
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim t = uc.NewTransformer()
      Dim Text = "This is a test."
      Dim p = t.FromTo("This {words:3}", "[{words}]")
      
      Console.WriteLine($"Input: {Text}")
      Console.WriteLine($"Pattern: {p.Pattern}")
      Console.WriteLine("")
      
      Console.WriteLine("3 captured tokens are in brackets")
      Console.WriteLine("")
      
      Console.WriteLine($"WhitespaceSensitive = {t.DefaultRuleSet.WhitespaceSensitive}")
      Console.WriteLine(t.Transform(Text))
      Console.WriteLine("")
      
      t.DefaultRuleSet.WhitespaceSensitive = true
      Console.WriteLine($"WhitespaceSensitive = {t.DefaultRuleSet.WhitespaceSensitive}")
      Console.WriteLine(t.Transform(Text))
      
   End Sub
End Module
				
			
Input: This is a test.
Pattern: This {words:3}

3 captured tokens are in brackets

WhitespaceSensitive = False
[is a test].

WhitespaceSensitive = True
[ is ]a test.