A practical example of extracting a complete HTML tag and its content from a string.
ID: 1276
See: BetweenInclusive
using uCalcSoftware;
var uc = new uCalc();
using (var s = new uCalc.String("Some text This is a paragraph.
more text.")) {
// Extract the entire paragraph tag, including its start and end tags.
var p_tag = s.BetweenInclusive("", "
");
Console.WriteLine(p_tag);
}
<p>This is a paragraph.</p> using uCalcSoftware; var uc = new uCalc(); using (var s = new uCalc.String("Some text <p>This is a paragraph.</p> more text.")) { // Extract the entire paragraph tag, including its start and end tags. var p_tag = s.BetweenInclusive("<p>", "</p>"); Console.WriteLine(p_tag); }
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
{
uCalc::String s("Some text This is a paragraph.
more text.");
s.Owned(); // Causes s to be released when it goes out of scope
// Extract the entire paragraph tag, including its start and end tags.
auto p_tag = s.BetweenInclusive("", "
");
cout << p_tag << endl;
}
}
<p>This is a paragraph.</p> #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; { uCalc::String s("Some text <p>This is a paragraph.</p> more text."); s.Owned(); // Causes s to be released when it goes out of scope // Extract the entire paragraph tag, including its start and end tags. auto p_tag = s.BetweenInclusive("<p>", "</p>"); cout << p_tag << endl; } }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Using s As New uCalc.String("Some text This is a paragraph.
more text.")
'// Extract the entire paragraph tag, including its start and end tags.
Dim p_tag = s.BetweenInclusive("", "
")
Console.WriteLine(p_tag)
End Using
End Sub
End Module
<p>This is a paragraph.</p> Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Using s As New uCalc.String("Some text <p>This is a paragraph.</p> more text.") '// Extract the entire paragraph tag, including its start and end tags. Dim p_tag = s.BetweenInclusive("<p>", "</p>") Console.WriteLine(p_tag) End Using End Sub End Module