Internal Test: Verifies that StartPosition is correct for multiple, non-contiguous matches.
ID: 831
using uCalcSoftware;
var uc = new uCalc();
var t = uc.NewTransformer();
t.Text = "a b c a d e a f g";
// ^ ^ ^
// Pos: 0 6 12
t.Pattern("a");
t.Find();
var matches = t.Matches;
Console.WriteLine($"Match 1 Start: {matches[0].StartPosition}"); // Should be 0
Console.WriteLine($"Match 2 Start: {matches[1].StartPosition}"); // Should be 6
Console.WriteLine($"Match 3 Start: {matches[2].StartPosition}"); // Should be 12
Match 1 Start: 0
Match 2 Start: 6
Match 3 Start: 12 using uCalcSoftware; var uc = new uCalc(); var t = uc.NewTransformer(); t.Text = "a b c a d e a f g"; // ^ ^ ^ // Pos: 0 6 12 t.Pattern("a"); t.Find(); var matches = t.Matches; Console.WriteLine($"Match 1 Start: {matches[0].StartPosition}"); // Should be 0 Console.WriteLine($"Match 2 Start: {matches[1].StartPosition}"); // Should be 6 Console.WriteLine($"Match 3 Start: {matches[2].StartPosition}"); // Should be 12
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
auto t = uc.NewTransformer();
t.Text("a b c a d e a f g");
// ^ ^ ^
// Pos: 0 6 12
t.Pattern("a");
t.Find();
auto matches = t.Matches();
cout << "Match 1 Start: " << matches[0].StartPosition() << endl; // Should be 0
cout << "Match 2 Start: " << matches[1].StartPosition() << endl; // Should be 6
cout << "Match 3 Start: " << matches[2].StartPosition() << endl; // Should be 12
}
Match 1 Start: 0
Match 2 Start: 6
Match 3 Start: 12 #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto t = uc.NewTransformer(); t.Text("a b c a d e a f g"); // ^ ^ ^ // Pos: 0 6 12 t.Pattern("a"); t.Find(); auto matches = t.Matches(); cout << "Match 1 Start: " << matches[0].StartPosition() << endl; // Should be 0 cout << "Match 2 Start: " << matches[1].StartPosition() << endl; // Should be 6 cout << "Match 3 Start: " << matches[2].StartPosition() << endl; // Should be 12 }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t = uc.NewTransformer()
t.Text = "a b c a d e a f g"
'// ^ ^ ^
'// Pos: 0 6 12
t.Pattern("a")
t.Find()
Dim matches = t.Matches
Console.WriteLine($"Match 1 Start: {matches(0).StartPosition}") '// Should be 0
Console.WriteLine($"Match 2 Start: {matches(1).StartPosition}") '// Should be 6
Console.WriteLine($"Match 3 Start: {matches(2).StartPosition}") '// Should be 12
End Sub
End Module
Match 1 Start: 0
Match 2 Start: 6
Match 3 Start: 12 Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t = uc.NewTransformer() t.Text = "a b c a d e a f g" '// ^ ^ ^ '// Pos: 0 6 12 t.Pattern("a") t.Find() Dim matches = t.Matches Console.WriteLine($"Match 1 Start: {matches(0).StartPosition}") '// Should be 0 Console.WriteLine($"Match 2 Start: {matches(1).StartPosition}") '// Should be 6 Console.WriteLine($"Match 3 Start: {matches(2).StartPosition}") '// Should be 12 End Sub End Module