using uCalcSoftware;
var uc = new uCalc();
var t = uc.NewTransformer();
// Ignore multi-line formatting
t.DefaultRuleSet.StatementSensitive = false;
// 1. Parent rule captures the content of the
using uCalcSoftware; var uc = new uCalc(); var t = uc.NewTransformer(); // Ignore multi-line formatting t.DefaultRuleSet.StatementSensitive = false; // 1. Parent rule captures the content of the <nav> block. var navRule = t.Pattern("<nav>{content}</nav>"); // 2. Get the local transformer for the nav block. var local_t = navRule.LocalTransformer; // 3. This rule will only find `<a>` tags inside the <nav> block. local_t.Pattern("<a href={url}>{text}</a>"); var html = """ <nav> <a href="/home">Home</a> <a href="/about">About</a> </nav> <main> <p>Some text with another <a href="/other">other link</a>.</p> </main> """; t.Text = html; t.Find(); Console.WriteLine("--- Found Links (Innermost Matches Only) ---"); // Use InnermostOnly to see only the results from the local transformer. Console.WriteLine(t.GetMatches(MatchesOption.InnermostOnly).Text);
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
auto t = uc.NewTransformer();
// Ignore multi-line formatting
t.DefaultRuleSet().StatementSensitive(false);
// 1. Parent rule captures the content of the block.
auto navRule = t.Pattern("{content}");
// 2. Get the local transformer for the nav block.
auto local_t = navRule.LocalTransformer();
// 3. This rule will only find `` tags inside the block.
local_t.Pattern("{text}");
auto html = R"(HomeAbout
)";
t.Text(html);
t.Find();
cout << "--- Found Links (Innermost Matches Only) ---" << endl;
// Use InnermostOnly to see only the results from the local transformer.
cout << t.GetMatches(MatchesOption::InnermostOnly).Text() << endl;
}
#include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto t = uc.NewTransformer(); // Ignore multi-line formatting t.DefaultRuleSet().StatementSensitive(false); // 1. Parent rule captures the content of the <nav> block. auto navRule = t.Pattern("<nav>{content}</nav>"); // 2. Get the local transformer for the nav block. auto local_t = navRule.LocalTransformer(); // 3. This rule will only find `<a>` tags inside the <nav> block. local_t.Pattern("<a href={url}>{text}</a>"); auto html = R"(<nav> <a href="/home">Home</a> <a href="/about">About</a> </nav> <main> <p>Some text with another <a href="/other">other link</a>.</p> </main>)"; t.Text(html); t.Find(); cout << "--- Found Links (Innermost Matches Only) ---" << endl; // Use InnermostOnly to see only the results from the local transformer. cout << t.GetMatches(MatchesOption::InnermostOnly).Text() << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t = uc.NewTransformer()
'// Ignore multi-line formatting
t.DefaultRuleSet.StatementSensitive = false
'// 1. Parent rule captures the content of the block.
Dim navRule = t.Pattern("{content}")
'// 2. Get the local transformer for the nav block.
Dim local_t = navRule.LocalTransformer
'// 3. This rule will only find `` tags inside the block.
local_t.Pattern("{text}")
Dim html = "HomeAbout
"
t.Text = html
t.Find()
Console.WriteLine("--- Found Links (Innermost Matches Only) ---")
'// Use InnermostOnly to see only the results from the local transformer.
Console.WriteLine(t.GetMatches(MatchesOption.InnermostOnly).Text)
End Sub
End Module
Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t = uc.NewTransformer() '// Ignore multi-line formatting t.DefaultRuleSet.StatementSensitive = false '// 1. Parent rule captures the content of the <nav> block. Dim navRule = t.Pattern("<nav>{content}</nav>") '// 2. Get the local transformer for the nav block. Dim local_t = navRule.LocalTransformer '// 3. This rule will only find `<a>` tags inside the <nav> block. local_t.Pattern("<a href={url}>{text}</a>") Dim html = "<nav> <a href=""/home"">Home</a> <a href=""/about"">About</a> </nav> <main> <p>Some text with another <a href=""/other"">other link</a>.</p> </main>" t.Text = html t.Find() Console.WriteLine("--- Found Links (Innermost Matches Only) ---") '// Use InnermostOnly to see only the results from the local transformer. Console.WriteLine(t.GetMatches(MatchesOption.InnermostOnly).Text) End Sub End Module