How to replace all occurrences of a string?
Regex.Replace(“you want to be in Microsoft because you deserve Good Life in this world”,@”[/you/]”,”i”);
Hi,
You can use string.replace() method with regular expression of global (g means replace it globally).
let str = "Mr blue has a blue house and a blue car";str.replace(/blue/g, "red");//Output: Mr red has a red house and a red car.
let str = "Mr blue has a blue house and a blue car";
str.replace(/blue/g, "red");
//Output: Mr red has a red house and a red car.
Hey. You need to use replace method. Check this video, https://youtu.be/DNiRjTaly4A
Use RegEx.Replace method
https://docs.microsoft.com/en-us/dotnet/api/system.text.regularexpressions.regex.replace?view=netcore-3.1
If we need to replace “Microsoft” with “Google” we can do it by:str.replace("Microsoft", "Google");
str.replace("Microsoft", "Google");