Iterating through multiple HTML tag matches and printing the text of each one.

ID: 838

				
					using uCalcSoftware;

var uc = new uCalc();
var t = uc.NewTransformer();
t.Text = "<p>First paragraph.</p> <div>Content</div>";

// Pattern to find any simple HTML-like tag
t.Pattern("<{tag}>{content}</{tag}>");
t.Find();

var matches = t.Matches;
Console.WriteLine($"Found {matches.Count()} tags:");
foreach(var match in t.Matches) {
   Console.WriteLine($"- {match.Text}");
}
				
			
Found 2 tags:
- <p>First paragraph.</p>
- <div>Content</div>
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   auto t = uc.NewTransformer();
   t.Text("<p>First paragraph.</p> <div>Content</div>");

   // Pattern to find any simple HTML-like tag
   t.Pattern("<{tag}>{content}</{tag}>");
   t.Find();

   auto matches = t.Matches();
   cout << "Found " << matches.Count() << " tags:" << endl;
   for(auto match : t.Matches()) {
      cout << "- " << match.Text() << endl;
   }
}
				
			
Found 2 tags:
- <p>First paragraph.</p>
- <div>Content</div>
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim t = uc.NewTransformer()
      t.Text = "<p>First paragraph.</p> <div>Content</div>"
      
      '// Pattern to find any simple HTML-like tag
      t.Pattern("<{tag}>{content}</{tag}>")
      t.Find()
      
      Dim matches = t.Matches
      Console.WriteLine($"Found {matches.Count()} tags:")
      For Each match In t.Matches
         Console.WriteLine($"- {match.Text}")
      Next
   End Sub
End Module
				
			
Found 2 tags:
- <p>First paragraph.</p>
- <div>Content</div>