uCalc API Version: 2.1.3-preview.2 Released: 6/16/2026
Warning
uCalc API Preview Release Notice:The documentation describes the intended behavior of the API. The current preview build contains incomplete features, unoptimized performance, and is subject to breaking changes.
BetweenInclusive
Method
Product:
Class:
Creates a live, modifiable view of the substring that includes the text between two specified patterns and the patterns themselves.
Syntax
Parameters
Return
String
A new uCalc.String object representing a live, modifiable view of the substring including the start and end patterns. Returns an empty string object if the patterns are not found.
Remarks
✂️ BetweenInclusive
The BetweenInclusive method finds the text that starts with a given pattern and ends with another, returning the entire segment including the boundary patterns themselves.
This method is part of the fluent, chainable API of the uCalc.String class.
Between vs. BetweenInclusive
This method is the inclusive counterpart to the Between method. The key difference is what they include in the result:
Between("A", "C"): FindsA B Cand returnsB.BetweenInclusive("A", "C"): FindsA B Cand returnsA B C.
✨ The "Live View" Concept
Like other extraction methods on uCalc.String, this method does not return a simple, disconnected substring. Instead, it returns a live, modifiable view into the parent string. This means any modifications made to the returned view will directly affect the content of the original parent string, enabling powerful in-place editing.
💡 Why uCalc? (Comparative Analysis)
In a standard language like C#, extracting a block including its delimiters requires finding the start and end indices and then calculating the correct length for Substring.
C# Manual Approach:
string text = "... <p>content</p> ...";string startTag = "<p>";string endTag = "</p>";int startIndex = text.IndexOf(startTag);int endIndex = text.IndexOf(endTag);if (startIndex != -1 && endIndex != -1){ string value = text.Substring(startIndex, (endIndex + endTag.Length) - startIndex); // 'value' is a new, disconnected string: "<p>content</p>"}This code is imperative and error-prone. uCalc provides a cleaner, more declarative solution:
The uCalc Advantage:
using (var s = new uCalc.String("... <p>content</p> ...")) {var tagView = s.BetweenInclusive("<p>", "</p>");// 'tagView' is a live view containing "<p>content</p>"// Modifying it changes the original string 's'.Console.WriteLine(tagView);}This approach is more readable, token-aware, and powerful due to the live-view architecture.
Examples
A succinct example extracting a parenthetical expression, including the parentheses.
using uCalcSoftware;
var uc = new uCalc();
using (var s = new uCalc.String("Calculate (10 * 5) and ignore this.")) {
// Get the text from the opening parenthesis to the closing one.
var expression = s.BetweenInclusive("(", ")");
Console.WriteLine(expression);
}
(10 * 5) using uCalcSoftware; var uc = new uCalc(); using (var s = new uCalc.String("Calculate (10 * 5) and ignore this.")) { // Get the text from the opening parenthesis to the closing one. var expression = s.BetweenInclusive("(", ")"); Console.WriteLine(expression); }
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
{
uCalc::String s("Calculate (10 * 5) and ignore this.");
s.Owned(); // Causes s to be released when it goes out of scope
// Get the text from the opening parenthesis to the closing one.
auto expression = s.BetweenInclusive("(", ")");
cout << expression << endl;
}
}
(10 * 5) #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; { uCalc::String s("Calculate (10 * 5) and ignore this."); s.Owned(); // Causes s to be released when it goes out of scope // Get the text from the opening parenthesis to the closing one. auto expression = s.BetweenInclusive("(", ")"); cout << expression << endl; } }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Using s As New uCalc.String("Calculate (10 * 5) and ignore this.")
'// Get the text from the opening parenthesis to the closing one.
Dim expression = s.BetweenInclusive("(", ")")
Console.WriteLine(expression)
End Using
End Sub
End Module
(10 * 5) Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Using s As New uCalc.String("Calculate (10 * 5) and ignore this.") '// Get the text from the opening parenthesis to the closing one. Dim expression = s.BetweenInclusive("(", ")") Console.WriteLine(expression) End Using End Sub End Module
A practical example of extracting a complete HTML tag and its content from a string.
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
Internal Test: Verifies the 'live view' behavior by modifying an extracted block and showing the change reflected in the parent string.
using uCalcSoftware;
var uc = new uCalc();
using (var s = new uCalc.String("root [child] end")) {
// Get a live view of the block including the brackets
var view = s.BetweenInclusive("'['", "']'");
Console.WriteLine($"Initial parent string: {s}");
Console.WriteLine($"Initial view: {view}");
// Modify the view. The change will propagate to the parent.
view.Replace("child", "MODIFIED");
Console.WriteLine($"Final parent string: {s}");
}
Initial parent string: root [child] end
Initial view: [child]
Final parent string: root [MODIFIED] end using uCalcSoftware; var uc = new uCalc(); using (var s = new uCalc.String("root [child] end")) { // Get a live view of the block including the brackets var view = s.BetweenInclusive("'['", "']'"); Console.WriteLine($"Initial parent string: {s}"); Console.WriteLine($"Initial view: {view}"); // Modify the view. The change will propagate to the parent. view.Replace("child", "MODIFIED"); Console.WriteLine($"Final parent string: {s}"); }
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
{
uCalc::String s("root [child] end");
s.Owned(); // Causes s to be released when it goes out of scope
// Get a live view of the block including the brackets
auto view = s.BetweenInclusive("'['", "']'");
cout << "Initial parent string: " << s << endl;
cout << "Initial view: " << view << endl;
// Modify the view. The change will propagate to the parent.
view.Replace("child", "MODIFIED");
cout << "Final parent string: " << s << endl;
}
}
Initial parent string: root [child] end
Initial view: [child]
Final parent string: root [MODIFIED] end #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; { uCalc::String s("root [child] end"); s.Owned(); // Causes s to be released when it goes out of scope // Get a live view of the block including the brackets auto view = s.BetweenInclusive("'['", "']'"); cout << "Initial parent string: " << s << endl; cout << "Initial view: " << view << endl; // Modify the view. The change will propagate to the parent. view.Replace("child", "MODIFIED"); cout << "Final parent string: " << s << endl; } }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Using s As New uCalc.String("root [child] end")
'// Get a live view of the block including the brackets
Dim view = s.BetweenInclusive("'['", "']'")
Console.WriteLine($"Initial parent string: {s}")
Console.WriteLine($"Initial view: {view}")
'// Modify the view. The change will propagate to the parent.
view.Replace("child", "MODIFIED")
Console.WriteLine($"Final parent string: {s}")
End Using
End Sub
End Module
Initial parent string: root [child] end
Initial view: [child]
Final parent string: root [MODIFIED] end Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Using s As New uCalc.String("root [child] end") '// Get a live view of the block including the brackets Dim view = s.BetweenInclusive("'['", "']'") Console.WriteLine($"Initial parent string: {s}") Console.WriteLine($"Initial view: {view}") '// Modify the view. The change will propagate to the parent. view.Replace("child", "MODIFIED") Console.WriteLine($"Final parent string: {s}") End Using End Sub End Module