How to dynamically enable or disable transformation rules using the Active property.
ID: 120
See: Active = [bool], Active(bool)
using uCalcSoftware;
var uc = new uCalc();
var t = uc.NewTransformer();
t.Str("Title
Bold statementTitle B
Other text");
var BoldTag = t.Pattern("{text}");
var H3Tag = t.Pattern("{text}
");
t.Find();
Console.WriteLine(t.Matches.Text);
Console.WriteLine("");
BoldTag.Active = false;
Console.WriteLine($"BoldTag.Active(): {BoldTag.Active}");
Console.WriteLine("-----------------------");
t.Find();
Console.WriteLine(t.Matches.Text);
Console.WriteLine("");
BoldTag.Active = true;
Console.WriteLine($"BoldTag.Active(): {BoldTag.Active}");
Console.WriteLine("----------------------");
t.Find();
Console.WriteLine(t.Matches.Text);
Console.WriteLine("");
<h3>Title</h3>
<b>Bold statement</b>
<h3>Title B</h3>
<b>Other text</b>
BoldTag.Active(): False
-----------------------
<h3>Title</h3>
<h3>Title B</h3>
BoldTag.Active(): True
----------------------
<h3>Title</h3>
<b>Bold statement</b>
<h3>Title B</h3>
<b>Other text</b> using uCalcSoftware; var uc = new uCalc(); var t = uc.NewTransformer(); t.Str("<h3>Title</h3><b>Bold statement</b><h3>Title B</h3><b>Other text</b>"); var BoldTag = t.Pattern("<b>{text}</b>"); var H3Tag = t.Pattern("<h3>{text}</h3>"); t.Find(); Console.WriteLine(t.Matches.Text); Console.WriteLine(""); BoldTag.Active = false; Console.WriteLine($"BoldTag.Active(): {BoldTag.Active}"); Console.WriteLine("-----------------------"); t.Find(); Console.WriteLine(t.Matches.Text); Console.WriteLine(""); BoldTag.Active = true; Console.WriteLine($"BoldTag.Active(): {BoldTag.Active}"); Console.WriteLine("----------------------"); t.Find(); Console.WriteLine(t.Matches.Text); Console.WriteLine("");
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
#define tf(IsTrue) ((IsTrue) ? "True" : "False")
int main() {
uCalc uc;
auto t = uc.NewTransformer();
t.Str("Title
Bold statementTitle B
Other text");
auto BoldTag = t.Pattern("{text}");
auto H3Tag = t.Pattern("{text}
");
t.Find();
cout << t.Matches().Text() << endl;
cout << "" << endl;
BoldTag.Active(false);
cout << "BoldTag.Active(): " << tf(BoldTag.Active()) << endl;
cout << "-----------------------" << endl;
t.Find();
cout << t.Matches().Text() << endl;
cout << "" << endl;
BoldTag.Active(true);
cout << "BoldTag.Active(): " << tf(BoldTag.Active()) << endl;
cout << "----------------------" << endl;
t.Find();
cout << t.Matches().Text() << endl;
cout << "" << endl;
}
<h3>Title</h3>
<b>Bold statement</b>
<h3>Title B</h3>
<b>Other text</b>
BoldTag.Active(): False
-----------------------
<h3>Title</h3>
<h3>Title B</h3>
BoldTag.Active(): True
----------------------
<h3>Title</h3>
<b>Bold statement</b>
<h3>Title B</h3>
<b>Other text</b> #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(); t.Str("<h3>Title</h3><b>Bold statement</b><h3>Title B</h3><b>Other text</b>"); auto BoldTag = t.Pattern("<b>{text}</b>"); auto H3Tag = t.Pattern("<h3>{text}</h3>"); t.Find(); cout << t.Matches().Text() << endl; cout << "" << endl; BoldTag.Active(false); cout << "BoldTag.Active(): " << tf(BoldTag.Active()) << endl; cout << "-----------------------" << endl; t.Find(); cout << t.Matches().Text() << endl; cout << "" << endl; BoldTag.Active(true); cout << "BoldTag.Active(): " << tf(BoldTag.Active()) << endl; cout << "----------------------" << endl; t.Find(); cout << t.Matches().Text() << endl; cout << "" << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t = uc.NewTransformer()
t.Str("Title
Bold statementTitle B
Other text")
Dim BoldTag = t.Pattern("{text}")
Dim H3Tag = t.Pattern("{text}
")
t.Find()
Console.WriteLine(t.Matches.Text)
Console.WriteLine("")
BoldTag.Active = false
Console.WriteLine($"BoldTag.Active(): {BoldTag.Active}")
Console.WriteLine("-----------------------")
t.Find()
Console.WriteLine(t.Matches.Text)
Console.WriteLine("")
BoldTag.Active = true
Console.WriteLine($"BoldTag.Active(): {BoldTag.Active}")
Console.WriteLine("----------------------")
t.Find()
Console.WriteLine(t.Matches.Text)
Console.WriteLine("")
End Sub
End Module
<h3>Title</h3>
<b>Bold statement</b>
<h3>Title B</h3>
<b>Other text</b>
BoldTag.Active(): False
-----------------------
<h3>Title</h3>
<h3>Title B</h3>
BoldTag.Active(): True
----------------------
<h3>Title</h3>
<b>Bold statement</b>
<h3>Title B</h3>
<b>Other text</b> Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t = uc.NewTransformer() t.Str("<h3>Title</h3><b>Bold statement</b><h3>Title B</h3><b>Other text</b>") Dim BoldTag = t.Pattern("<b>{text}</b>") Dim H3Tag = t.Pattern("<h3>{text}</h3>") t.Find() Console.WriteLine(t.Matches.Text) Console.WriteLine("") BoldTag.Active = false Console.WriteLine($"BoldTag.Active(): {BoldTag.Active}") Console.WriteLine("-----------------------") t.Find() Console.WriteLine(t.Matches.Text) Console.WriteLine("") BoldTag.Active = true Console.WriteLine($"BoldTag.Active(): {BoldTag.Active}") Console.WriteLine("----------------------") t.Find() Console.WriteLine(t.Matches.Text) Console.WriteLine("") End Sub End Module