Returns Start and End positions of Transformer matches
ID: 788
See: EndPosition = [int]
using uCalcSoftware;
var uc = new uCalc();
var t = uc.NewTransformer();
t.Text = "
First
Blah Blah
Testing
Second
";
// ^ ^ ^ ^
// 012345678901234567890123456789012345678901234567890123456789
// 0 10 20 30 40 50
// Carrets (^) point to Start and End locations of the matches
Console.WriteLine(t.Text);
Console.WriteLine("");
t.Pattern("<{tag}>{etc}{tag}>");
t.Find();
var Matches = t.Matches;
Console.WriteLine(Matches[0].Text);
Console.WriteLine($"Start pos: {Matches[0].StartPosition}");
Console.WriteLine($"End pos: {Matches[0].EndPosition}");
Console.WriteLine($"Length: {Matches[0].Length}");
Console.WriteLine("");
Console.WriteLine(Matches[1].Text);
Console.WriteLine($"Start pos: {Matches[1].StartPosition}");
Console.WriteLine($"End pos: {Matches[1].EndPosition}");
Console.WriteLine($"Length: {Matches[1].Length}");
<br><h1>First</h1>Blah Blah<br>Testing<br><h2>Second</h2>
<h1>First</h1>
Start pos: 4
End pos: 18
Length: 14
<h2>Second</h2>
Start pos: 42
End pos: 57
Length: 15 using uCalcSoftware; var uc = new uCalc(); var t = uc.NewTransformer(); t.Text = "<br><h1>First</h1>Blah Blah<br>Testing<br><h2>Second</h2>"; // ^ ^ ^ ^ // 012345678901234567890123456789012345678901234567890123456789 // 0 10 20 30 40 50 // Carrets (^) point to Start and End locations of the matches Console.WriteLine(t.Text); Console.WriteLine(""); t.Pattern("<{tag}>{etc}</{tag}>"); t.Find(); var Matches = t.Matches; Console.WriteLine(Matches[0].Text); Console.WriteLine($"Start pos: {Matches[0].StartPosition}"); Console.WriteLine($"End pos: {Matches[0].EndPosition}"); Console.WriteLine($"Length: {Matches[0].Length}"); Console.WriteLine(""); Console.WriteLine(Matches[1].Text); Console.WriteLine($"Start pos: {Matches[1].StartPosition}"); Console.WriteLine($"End pos: {Matches[1].EndPosition}"); Console.WriteLine($"Length: {Matches[1].Length}");
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
auto t = uc.NewTransformer();
t.Text("
First
Blah Blah
Testing
Second
");
// ^ ^ ^ ^
// 012345678901234567890123456789012345678901234567890123456789
// 0 10 20 30 40 50
// Carrets (^) point to Start and End locations of the matches
cout << t.Text() << endl;
cout << "" << endl;
t.Pattern("<{tag}>{etc}{tag}>");
t.Find();
auto Matches = t.Matches();
cout << Matches[0].Text() << endl;
cout << "Start pos: " << Matches[0].StartPosition() << endl;
cout << "End pos: " << Matches[0].EndPosition() << endl;
cout << "Length: " << Matches[0].Length() << endl;
cout << "" << endl;
cout << Matches[1].Text() << endl;
cout << "Start pos: " << Matches[1].StartPosition() << endl;
cout << "End pos: " << Matches[1].EndPosition() << endl;
cout << "Length: " << Matches[1].Length() << endl;
}
<br><h1>First</h1>Blah Blah<br>Testing<br><h2>Second</h2>
<h1>First</h1>
Start pos: 4
End pos: 18
Length: 14
<h2>Second</h2>
Start pos: 42
End pos: 57
Length: 15 #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto t = uc.NewTransformer(); t.Text("<br><h1>First</h1>Blah Blah<br>Testing<br><h2>Second</h2>"); // ^ ^ ^ ^ // 012345678901234567890123456789012345678901234567890123456789 // 0 10 20 30 40 50 // Carrets (^) point to Start and End locations of the matches cout << t.Text() << endl; cout << "" << endl; t.Pattern("<{tag}>{etc}</{tag}>"); t.Find(); auto Matches = t.Matches(); cout << Matches[0].Text() << endl; cout << "Start pos: " << Matches[0].StartPosition() << endl; cout << "End pos: " << Matches[0].EndPosition() << endl; cout << "Length: " << Matches[0].Length() << endl; cout << "" << endl; cout << Matches[1].Text() << endl; cout << "Start pos: " << Matches[1].StartPosition() << endl; cout << "End pos: " << Matches[1].EndPosition() << endl; cout << "Length: " << Matches[1].Length() << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t = uc.NewTransformer()
t.Text = "
First
Blah Blah
Testing
Second
"
'// ^ ^ ^ ^
'// 012345678901234567890123456789012345678901234567890123456789
'// 0 10 20 30 40 50
'// Carrets (^) point to Start and End locations of the matches
Console.WriteLine(t.Text)
Console.WriteLine("")
t.Pattern("<{tag}>{etc}{tag}>")
t.Find()
Dim Matches = t.Matches
Console.WriteLine(Matches(0).Text)
Console.WriteLine($"Start pos: {Matches(0).StartPosition}")
Console.WriteLine($"End pos: {Matches(0).EndPosition}")
Console.WriteLine($"Length: {Matches(0).Length}")
Console.WriteLine("")
Console.WriteLine(Matches(1).Text)
Console.WriteLine($"Start pos: {Matches(1).StartPosition}")
Console.WriteLine($"End pos: {Matches(1).EndPosition}")
Console.WriteLine($"Length: {Matches(1).Length}")
End Sub
End Module
<br><h1>First</h1>Blah Blah<br>Testing<br><h2>Second</h2>
<h1>First</h1>
Start pos: 4
End pos: 18
Length: 14
<h2>Second</h2>
Start pos: 42
End pos: 57
Length: 15 Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t = uc.NewTransformer() t.Text = "<br><h1>First</h1>Blah Blah<br>Testing<br><h2>Second</h2>" '// ^ ^ ^ ^ '// 012345678901234567890123456789012345678901234567890123456789 '// 0 10 20 30 40 50 '// Carrets (^) point to Start and End locations of the matches Console.WriteLine(t.Text) Console.WriteLine("") t.Pattern("<{tag}>{etc}</{tag}>") t.Find() Dim Matches = t.Matches Console.WriteLine(Matches(0).Text) Console.WriteLine($"Start pos: {Matches(0).StartPosition}") Console.WriteLine($"End pos: {Matches(0).EndPosition}") Console.WriteLine($"Length: {Matches(0).Length}") Console.WriteLine("") Console.WriteLine(Matches(1).Text) Console.WriteLine($"Start pos: {Matches(1).StartPosition}") Console.WriteLine($"End pos: {Matches(1).EndPosition}") Console.WriteLine($"Length: {Matches(1).Length}") End Sub End Module