uCalc API Version: 2.1.3-preview.2 Released: 6/17/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.

After

Method

Product: 

String Library

Class: 

String

Creates a live, modifiable view of the substring that follows a specified pattern match.

Syntax

After(string, int)

Parameters

pattern
string
The pattern to find. The returned view will start immediately after this pattern's match.
nth
int
(Default = 1)
The 1-based occurrence of the pattern to find. For example, a value of 2 finds the second match.

Return

String

A new uCalc.String object that is a live, modifiable view into the portion of the parent string that comes after the specified pattern match. Returns an empty string object if the pattern is not found or if nothing follows it.

Remarks

✂️ Extracting Text After a Pattern

The After method finds the nth occurrence of a given pattern and returns a new uCalc.String object representing all the text that follows it. This is a fundamental tool for parsing data and is part of uCalc.String's fluent, chainable API.

Note: This method may be renamed to StartAfter in a future version for better consistency with the Rule.StartAfter property.

✨ The "Live View" Concept

The most important feature of this method is that it 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 child string (the returned view) will directly affect the content of the original parent string.
  • This allows for powerful, in-place editing of specific sections of a larger document without the overhead of creating and rejoining substrings.

⚙️ Parameters

  • pattern: The uCalc pattern to search for. This can be a simple literal or a complex pattern with variables.
  • nth: A 1-based index specifying which occurrence of the pattern to find. The default value of 1 finds the first match.

Behavior on Failure

If the specified pattern is not found, or if nothing comes after it, the method returns an empty uCalc.String object. No error is raised.

💡 Why uCalc? (Comparative Analysis)

In a standard language like C#, you would typically find the end position of a match and then create a new substring.

C# Manual Approach:

string text = "ID: 12345";string prefix = "ID: ";int startIndex = text.IndexOf(prefix);if (startIndex != -1){    string value = text.Substring(startIndex + prefix.Length);    // 'value' is now a new, disconnected string "12345"}

This approach is imperative and creates disconnected data. uCalc.String provides a more powerful, declarative, and integrated solution:

The uCalc Advantage:

var s = new uCalc.String("ID: 12345");var valueView = s.After("ID: "); // Returns a live view// Modifying the view changes the original string 's'valueView.Replace("12345", "CHANGED");Console.WriteLine(s); // Output: ID: CHANGED

This ability to create live, chainable views is a key differentiator, enabling a more fluid and powerful style of text manipulation that is not possible with standard string libraries.

Examples

A succinct example that extracts a value from a simple key-value pair.
				
					using uCalcSoftware;

var uc = new uCalc();
using (var s = new uCalc.String("ID: 12345")) {
   
   // Get the text after the "ID: " prefix
   var value = s.After("ID: ");

   Console.WriteLine(value);
}
				
			
 12345
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   {
      uCalc::String s("ID: 12345");
      s.Owned(); // Causes s to be released when it goes out of scope

      // Get the text after the "ID: " prefix
      auto value = s.After("ID: ");

      cout << value << endl;
   }
}
				
			
 12345
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Using s As New uCalc.String("ID: 12345")
         
         '// Get the text after the "ID: " prefix
         Dim value = s.After("ID: ")
         
         Console.WriteLine(value)
      End Using
   End Sub
End Module
				
			
 12345
A practical example demonstrating how to extract an error message from a log entry and then chain another operation on the result.
				
					using uCalcSoftware;

var uc = new uCalc();
using (var log = new uCalc.String("INFO: Task complete. ERROR: File not found.")) {
   
   // Chain After() to isolate the error, then Replace() to modify it.
   var errorDetails = log.After("ERROR: ").Replace("File", "Resource");

   Console.WriteLine($"Original log: {log}");      // The original string is modified in-place
   Console.WriteLine($"Modified details:{errorDetails}"); // The view reflects the change
}
				
			
Original log: INFO: Task complete. ERROR: Resource not found.
Modified details: Resource not found.
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   {
      uCalc::String log("INFO: Task complete. ERROR: File not found.");
      log.Owned(); // Causes log to be released when it goes out of scope

      // Chain After() to isolate the error, then Replace() to modify it.
      auto errorDetails = log.After("ERROR: ").Replace("File", "Resource");

      cout << "Original log: " << log << endl;      // The original string is modified in-place
      cout << "Modified details:" << errorDetails << endl; // The view reflects the change
   }
}
				
			
Original log: INFO: Task complete. ERROR: Resource not found.
Modified details: Resource not found.
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Using log As New uCalc.String("INFO: Task complete. ERROR: File not found.")
         
         '// Chain After() to isolate the error, then Replace() to modify it.
         Dim errorDetails = log.After("ERROR: ").Replace("File", "Resource")
         
         Console.WriteLine($"Original log: {log}")      '// The original string is modified in-place
         Console.WriteLine($"Modified details:{errorDetails}") '// The view reflects the change
      End Using
   End Sub
End Module
				
			
Original log: INFO: Task complete. ERROR: Resource not found.
Modified details: Resource not found.
Internal Test: Verifies behavior for patterns at the end of the string and patterns that are not found.
				
					using uCalcSoftware;

var uc = new uCalc();
using (var s = new uCalc.String("A B C")) {
   
   // Case 1: Pattern is at the end. Should return an empty string.
   Console.Write("After 'C': '");
   Console.Write(s.After("C"));
   Console.WriteLine("'");

   // Case 2: Pattern does not exist. Should return an empty string.
   Console.Write("After 'D': '");
   Console.Write(s.After("D"));
   Console.WriteLine("'");

   // Case 3: Get text after the first word.
   Console.Write("After 'A': '");
   Console.Write(s.After("A"));
   Console.WriteLine("'");
}
				
			
After 'C': ''
After 'D': ''
After 'A': ' B C'
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   {
      uCalc::String s("A B C");
      s.Owned(); // Causes s to be released when it goes out of scope

      // Case 1: Pattern is at the end. Should return an empty string.
      cout << "After 'C': '";
      cout << s.After("C");
      cout << "'" << endl;

      // Case 2: Pattern does not exist. Should return an empty string.
      cout << "After 'D': '";
      cout << s.After("D");
      cout << "'" << endl;

      // Case 3: Get text after the first word.
      cout << "After 'A': '";
      cout << s.After("A");
      cout << "'" << endl;
   }
}
				
			
After 'C': ''
After 'D': ''
After 'A': ' B C'
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Using s As New uCalc.String("A B C")
         
         '// Case 1: Pattern is at the end. Should return an empty string.
         Console.Write("After 'C': '")
         Console.Write(s.After("C"))
         Console.WriteLine("'")
         
         '// Case 2: Pattern does not exist. Should return an empty string.
         Console.Write("After 'D': '")
         Console.Write(s.After("D"))
         Console.WriteLine("'")
         
         '// Case 3: Get text after the first word.
         Console.Write("After 'A': '")
         Console.Write(s.After("A"))
         Console.WriteLine("'")
      End Using
   End Sub
End Module
				
			
After 'C': ''
After 'D': ''
After 'A': ' B C'
How to extract text that appears after a specific pattern using the String.After() method.
				
					using uCalcSoftware;

var uc = new uCalc();
uCalc.String s = "This is just a test";
Console.WriteLine(s.After("is"));

s = "/* if else */ if (x > 100) y = x * 2; else if(x == 5) y = x - 1;";
Console.WriteLine(s.After("if ({cond})"));
Console.WriteLine(s.After("if ({cond})").After("if ({cond})"));
Console.WriteLine(s.After("if ({cond})", 2)); // Finds text after 2nd match (same as above)
Console.WriteLine(s.After("NonExistingPattern")); // Nothing to display on this line
Console.WriteLine("----");

				
			
 just a test
 y = x * 2; else if(x == 5) y = x - 1;
 y = x - 1;
 y = x - 1;

----
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   uCalc::String s = "This is just a test";
   cout << s.After("is") << endl;

   s = "/* if else */ if (x > 100) y = x * 2; else if(x == 5) y = x - 1;";
   cout << s.After("if ({cond})") << endl;
   cout << s.After("if ({cond})").After("if ({cond})") << endl;
   cout << s.After("if ({cond})", 2) << endl; // Finds text after 2nd match (same as above)
   cout << s.After("NonExistingPattern") << endl; // Nothing to display on this line
   cout << "----" << endl;

}
				
			
 just a test
 y = x * 2; else if(x == 5) y = x - 1;
 y = x - 1;
 y = x - 1;

----
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim s As uCalc.String = "This is just a test"
      Console.WriteLine(s.After("is"))
      
      s = "/* if else */ if (x > 100) y = x * 2; else if(x == 5) y = x - 1;"
      Console.WriteLine(s.After("if ({cond})"))
      Console.WriteLine(s.After("if ({cond})").After("if ({cond})"))
      Console.WriteLine(s.After("if ({cond})", 2)) '// Finds text after 2nd match (same as above)
      Console.WriteLine(s.After("NonExistingPattern")) '// Nothing to display on this line
      Console.WriteLine("----")
      
   End Sub
End Module
				
			
 just a test
 y = x * 2; else if(x == 5) y = x - 1;
 y = x - 1;
 y = x - 1;

----