![]() |
VOOZH | about |
The replace() method in TypeScript is used to find matches between a regular expression or a substring and a string, replacing the matched substring with a new substring or the value returned by a function.
string.replace(regexp/substr, newSubStr/function[, flags]);Parameter: This method accepts five parameters as mentioned above and described below:
Return Value: This method returns a new changed string.
Below example illustrate the String replace() method in TypeScriptJS:
This example demonstrates how to replace a simple substring with another string.
Output:
Geeksforgeeks is a best platform.This example shows how to replace all occurrences of a substring using a regular expression.
Output:
TypeScript JavaScript JavaScript