Replace

Method

Replaces occurences of a pattern with something else

Product: 

Class: 

Warning

uCalc API Preview Release Notice:The uCalc engine has successfully transitioned to modern cross-platform environments.The next phase envolves some structural changes, performance optimizations, and API refinements.The API is subject to breaking changes prior to the stable release. Please evaluate the preview version thoroughly before production use.

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

This page last modified on: 

8/21/2026