BracketSensitive
ID: 121
using uCalcSoftware;
var uc = new uCalc();
var t = uc.NewTransformer();
var Pattern = t.Pattern("< {etc} >");
t.Str("< a b c > d < (e f g) > h < (i) (j k) > l < m n o ( > p) q >");
// Note the difference in the final match
Pattern.BracketSensitive = true; // true is the default
Console.WriteLine($"BracketSensitive: {Pattern.BracketSensitive}");
Console.WriteLine("----------------------");
t.Find();
Console.WriteLine(t.Matches.Text);
Console.WriteLine("");
Pattern.BracketSensitive = false;
Console.WriteLine($"BracketSensitive: {Pattern.BracketSensitive}");
Console.WriteLine("-----------------------");
t.Find();
Console.WriteLine(t.Matches.Text);
Console.WriteLine("");
t.Str("( a b ( c ) d e )");
// Here parentheses are captured as regular tokens, not bracket pairs
var Pattern2a = t.Pattern("( {etc} (");
var Pattern2b = t.Pattern(") {etc} )");
Console.WriteLine("Brackets used as part of pattern");
Console.WriteLine("--------------------------------");
Pattern2a.BracketSensitive = true;
Pattern2b.BracketSensitive = true;
t.Find();
Console.WriteLine(t.Matches.Text);
Console.WriteLine("");
Pattern2a.BracketSensitive = false;
Pattern2b.BracketSensitive = false;
t.Find();
Console.WriteLine(t.Matches.Text);
BracketSensitive: True
----------------------
< a b c >
< (e f g) >
< (i) (j k) >
< m n o ( > p) q >
BracketSensitive: False
-----------------------
< a b c >
< (e f g) >
< (i) (j k) >
< m n o ( >
Brackets used as part of pattern
--------------------------------
( a b (
) d e )
( a b (
) d e ) using uCalcSoftware; var uc = new uCalc(); var t = uc.NewTransformer(); var Pattern = t.Pattern("< {etc} >"); t.Str("< a b c > d < (e f g) > h < (i) (j k) > l < m n o ( > p) q >"); // Note the difference in the final match Pattern.BracketSensitive = true; // true is the default Console.WriteLine($"BracketSensitive: {Pattern.BracketSensitive}"); Console.WriteLine("----------------------"); t.Find(); Console.WriteLine(t.Matches.Text); Console.WriteLine(""); Pattern.BracketSensitive = false; Console.WriteLine($"BracketSensitive: {Pattern.BracketSensitive}"); Console.WriteLine("-----------------------"); t.Find(); Console.WriteLine(t.Matches.Text); Console.WriteLine(""); t.Str("( a b ( c ) d e )"); // Here parentheses are captured as regular tokens, not bracket pairs var Pattern2a = t.Pattern("( {etc} ("); var Pattern2b = t.Pattern(") {etc} )"); Console.WriteLine("Brackets used as part of pattern"); Console.WriteLine("--------------------------------"); Pattern2a.BracketSensitive = true; Pattern2b.BracketSensitive = true; t.Find(); Console.WriteLine(t.Matches.Text); Console.WriteLine(""); Pattern2a.BracketSensitive = false; Pattern2b.BracketSensitive = false; t.Find(); Console.WriteLine(t.Matches.Text);
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
#define tf(IsTrue) ((IsTrue) ? "True" : "False")
int main() {
uCalc uc;
auto t = uc.NewTransformer();
auto Pattern = t.Pattern("< {etc} >");
t.Str("< a b c > d < (e f g) > h < (i) (j k) > l < m n o ( > p) q >");
// Note the difference in the final match
Pattern.BracketSensitive(true); // true is the default
cout << "BracketSensitive: " << tf(Pattern.BracketSensitive()) << endl;
cout << "----------------------" << endl;
t.Find();
cout << t.Matches().Text() << endl;
cout << "" << endl;
Pattern.BracketSensitive(false);
cout << "BracketSensitive: " << tf(Pattern.BracketSensitive()) << endl;
cout << "-----------------------" << endl;
t.Find();
cout << t.Matches().Text() << endl;
cout << "" << endl;
t.Str("( a b ( c ) d e )");
// Here parentheses are captured as regular tokens, not bracket pairs
auto Pattern2a = t.Pattern("( {etc} (");
auto Pattern2b = t.Pattern(") {etc} )");
cout << "Brackets used as part of pattern" << endl;
cout << "--------------------------------" << endl;
Pattern2a.BracketSensitive(true);
Pattern2b.BracketSensitive(true);
t.Find();
cout << t.Matches().Text() << endl;
cout << "" << endl;
Pattern2a.BracketSensitive(false);
Pattern2b.BracketSensitive(false);
t.Find();
cout << t.Matches().Text() << endl;
}
BracketSensitive: True
----------------------
< a b c >
< (e f g) >
< (i) (j k) >
< m n o ( > p) q >
BracketSensitive: False
-----------------------
< a b c >
< (e f g) >
< (i) (j k) >
< m n o ( >
Brackets used as part of pattern
--------------------------------
( a b (
) d e )
( a b (
) d e ) #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 Pattern = t.Pattern("< {etc} >"); t.Str("< a b c > d < (e f g) > h < (i) (j k) > l < m n o ( > p) q >"); // Note the difference in the final match Pattern.BracketSensitive(true); // true is the default cout << "BracketSensitive: " << tf(Pattern.BracketSensitive()) << endl; cout << "----------------------" << endl; t.Find(); cout << t.Matches().Text() << endl; cout << "" << endl; Pattern.BracketSensitive(false); cout << "BracketSensitive: " << tf(Pattern.BracketSensitive()) << endl; cout << "-----------------------" << endl; t.Find(); cout << t.Matches().Text() << endl; cout << "" << endl; t.Str("( a b ( c ) d e )"); // Here parentheses are captured as regular tokens, not bracket pairs auto Pattern2a = t.Pattern("( {etc} ("); auto Pattern2b = t.Pattern(") {etc} )"); cout << "Brackets used as part of pattern" << endl; cout << "--------------------------------" << endl; Pattern2a.BracketSensitive(true); Pattern2b.BracketSensitive(true); t.Find(); cout << t.Matches().Text() << endl; cout << "" << endl; Pattern2a.BracketSensitive(false); Pattern2b.BracketSensitive(false); t.Find(); cout << t.Matches().Text() << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t = uc.NewTransformer()
Dim Pattern = t.Pattern("< {etc} >")
t.Str("< a b c > d < (e f g) > h < (i) (j k) > l < m n o ( > p) q >")
'// Note the difference in the final match
Pattern.BracketSensitive = true '// true is the default
Console.WriteLine($"BracketSensitive: {Pattern.BracketSensitive}")
Console.WriteLine("----------------------")
t.Find()
Console.WriteLine(t.Matches.Text)
Console.WriteLine("")
Pattern.BracketSensitive = false
Console.WriteLine($"BracketSensitive: {Pattern.BracketSensitive}")
Console.WriteLine("-----------------------")
t.Find()
Console.WriteLine(t.Matches.Text)
Console.WriteLine("")
t.Str("( a b ( c ) d e )")
'// Here parentheses are captured as regular tokens, not bracket pairs
Dim Pattern2a = t.Pattern("( {etc} (")
Dim Pattern2b = t.Pattern(") {etc} )")
Console.WriteLine("Brackets used as part of pattern")
Console.WriteLine("--------------------------------")
Pattern2a.BracketSensitive = true
Pattern2b.BracketSensitive = true
t.Find()
Console.WriteLine(t.Matches.Text)
Console.WriteLine("")
Pattern2a.BracketSensitive = false
Pattern2b.BracketSensitive = false
t.Find()
Console.WriteLine(t.Matches.Text)
End Sub
End Module
BracketSensitive: True
----------------------
< a b c >
< (e f g) >
< (i) (j k) >
< m n o ( > p) q >
BracketSensitive: False
-----------------------
< a b c >
< (e f g) >
< (i) (j k) >
< m n o ( >
Brackets used as part of pattern
--------------------------------
( a b (
) d e )
( a b (
) d e ) Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t = uc.NewTransformer() Dim Pattern = t.Pattern("< {etc} >") t.Str("< a b c > d < (e f g) > h < (i) (j k) > l < m n o ( > p) q >") '// Note the difference in the final match Pattern.BracketSensitive = true '// true is the default Console.WriteLine($"BracketSensitive: {Pattern.BracketSensitive}") Console.WriteLine("----------------------") t.Find() Console.WriteLine(t.Matches.Text) Console.WriteLine("") Pattern.BracketSensitive = false Console.WriteLine($"BracketSensitive: {Pattern.BracketSensitive}") Console.WriteLine("-----------------------") t.Find() Console.WriteLine(t.Matches.Text) Console.WriteLine("") t.Str("( a b ( c ) d e )") '// Here parentheses are captured as regular tokens, not bracket pairs Dim Pattern2a = t.Pattern("( {etc} (") Dim Pattern2b = t.Pattern(") {etc} )") Console.WriteLine("Brackets used as part of pattern") Console.WriteLine("--------------------------------") Pattern2a.BracketSensitive = true Pattern2b.BracketSensitive = true t.Find() Console.WriteLine(t.Matches.Text) Console.WriteLine("") Pattern2a.BracketSensitive = false Pattern2b.BracketSensitive = false t.Find() Console.WriteLine(t.Matches.Text) End Sub End Module