Hello and welcome to the Golang programming language course.
In the previous session, we talked about fields function in this string, and in this session we want
to talk about the other extinct concept.
Go blank, replace function, the replace function, replace some characters with some other characters
in history.
Now you can see the scene techs.
In a specified number of characters that you want to replace in history, if any, is less than zero.
There is no limit on the number of replacements.
The function will replace all non-overlapping instances.
Of all the new in a string, yes, is if old is empty, then it inserts new between it.
Each valid UTF eight sequence of bias in their string is and if an is negative, then all instances
of old will be replaced with new.
Let's go to a school program to illustrate how to use replace function.
First, create a string variable and assign the replace function to it for the example defined resolved
call column equals.
The strings package don't replace function
for first argument.
We set a string value, for the example.
A B C D, that's a b c d, then select part of the created string as old arguments like a B and then
define the string that is to replace the selected string as new like asterisk asterisk.
And then a specified number of characters that you want to replace in history as an argument like one.
Now, display, the result may either be resolved by labor and right another sample like the previous
sample, except that we changed the value of end to minus one.
So we see resolved equals history strings.
Thoughts three place
a b, c, d, d, d, b, c, d,
a b minus three asterisk and sit in argument by minus one value.
And again, this a result.
OK.
Reformative called Save the Project, then execute the program.
Now we can see the output in the first sample because the value of N is one, the value of the asterisk
changed by only one value of a b, but in the second sample, because the value of N has changed below
zero.
Any number of abs will be replaced by asterisk.
OK.
In order not to prolong the time of decision, we will finish it and we will continue the content in
the next session.
Goodbye.