A practical example that finds all HTML-style tags and prints the text of each one.

ID: 833

				
					using uCalcSoftware;

var uc = new uCalc();
var t = uc.NewTransformer();
t.Text = "<h1>Title</h1><p>Text</p>";

// Pattern to find any tag and its content
t.Pattern("<{tag}>{content}</{tag}>");
t.Find();

var allMatches = t.Matches;
Console.WriteLine($"Found {allMatches.Count()} matches:");

// Loop through each Match object and print its Text
foreach(var match in allMatches) {
   Console.WriteLine($" - {match.Text}");
}
				
			
Found 2 matches:
 - <h1>Title</h1>
 - <p>Text</p>
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   auto t = uc.NewTransformer();
   t.Text("<h1>Title</h1><p>Text</p>");

   // Pattern to find any tag and its content
   t.Pattern("<{tag}>{content}</{tag}>");
   t.Find();

   auto allMatches = t.Matches();
   cout << "Found " << allMatches.Count() << " matches:" << endl;

   // Loop through each Match object and print its Text
   for(auto match : allMatches) {
      cout << " - " << match.Text() << endl;
   }
}
				
			
Found 2 matches:
 - <h1>Title</h1>
 - <p>Text</p>
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim t = uc.NewTransformer()
      t.Text = "<h1>Title</h1><p>Text</p>"
      
      '// Pattern to find any tag and its content
      t.Pattern("<{tag}>{content}</{tag}>")
      t.Find()
      
      Dim allMatches = t.Matches
      Console.WriteLine($"Found {allMatches.Count()} matches:")
      
      '// Loop through each Match object and print its Text
      For Each match In allMatches
         Console.WriteLine($" - {match.Text}")
      Next
   End Sub
End Module
				
			
Found 2 matches:
 - <h1>Title</h1>
 - <p>Text</p>