uCalc API Version: 5.7.0-preview.1 Released: 7/30/2026

Warning

uCalc API Preview Release Notice:This preview documentation describes the intended behavior of the API. It is not fully accurate or complete.The current preview build contains incomplete features, unoptimized performance, and is subject to breaking changes.Use of the preview version in your production code is not recommended.

Replace

Method

Product: 

Class: 

Replaces occurences of a pattern with something else

Syntax

Replace(string, string)

Parameters

From_
string
patter of occurence to match
To_
string
replacement of occurence

Return

String

uCalc String object

Remarks

Replaces occurrences of a pattern with something else.

Examples

Demonstrating in-place modification with uCalc.String.Replace

ID: 227

See: Replace
				
					using uCalcSoftware;

var uc = new uCalc();
uCalc.String text = "This is foo 1, foo 2, Foo 3, foo 4";
text.After("1").Before("3").Replace("foo", "bar"); // 'text' is now modified
Console.WriteLine(text);
				
			
This is foo 1, bar 2, bar 3, foo 4
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   uCalc::String text = "This is foo 1, foo 2, Foo 3, foo 4";
   text.After("1").Before("3").Replace("foo", "bar"); // 'text' is now modified
   cout << text << endl;
}
				
			
This is foo 1, bar 2, bar 3, foo 4
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim text As uCalc.String = "This is foo 1, foo 2, Foo 3, foo 4"
      text.After("1").Before("3").Replace("foo", "bar") '// 'text' is now modified
      Console.WriteLine(text)
   End Sub
End Module
				
			
This is foo 1, bar 2, bar 3, foo 4