Welcome back.
The last lecture we have detected, the links inside the input text in this lecture.
We're going to mask links.
When the program detects the link, it should mask the link until the link.
And to do that, we need to know whether we are inside of a link or not.
I will use a bool variable to keep track of it and I'm going to enable it here whenever we are inside
of a link.
Here we are adding everybody from the input to the buffer.
However, while we are inside of a link, we should only add the masking character instead.
So the link will be replaced by the masking character.
Let me cut the current byte form here.
Let me replace it with this.
And lastly, let me assign the current budget to a new variable like this.
OK, after this small refactoring.
Now I'm ready to mask the current bytes here.
I'm going to set the current pipe to the mass character, and I'm only going to do so if we are inside
of a link.
By the way, while in here, let's put this Maskin character into a constant Lexar.
Here, let's assign the mass constant instead.
By the way, the mask is a single character, right?
That's why I put it in a room, literal instead of a string.
This is more efficient because it is just a number.
Here's a tip for you.
When you are working with whites, continue working with whites.
Do not convert a string to a bachelor's or a bachelor's to a string on this necessary.
I prefer to work with whites mostly because they are more efficient and used everywhere in Go Standard
Library.
OK, let me try it.
Cool, now when it sees a link, it masks it, however, there is a problem, it also masks the rest
of the input.
So this leads us to our next goal, stop masking when white space is detected.
OK, for now, let's pause the link pattern, and whenever we see one of the whitespace characters,
such as a space or a new line and so on, to do that, I'm going to use a switch statement like so.
And when I did that white space, I'm going to stop the masking by setting the invariable to false.
So the program will know that it's not inside of a link anymore.
OK, let's run it.
Cool, now it only masks the link, not the rest of the input text, that was easy, right?
OK, let's check out our last call, Puttan, HDP prefix in front of the masked link.
I can do that very easily.
I'm just going to expand the link to the buffer, so.
This is a special case for the apan function, you can append a string to a bachelor's by adding three.
That's after the string value like so here it opens the bytes of the links, string the buff by slice.
OK, let's try it.
Cool, as you can see, it's first Prince staged perfect, then it masks the link.
However, there is one little problem here in the input link.
There are eight characters, but the program prints 15 stars instead.
Why does it do so?
If I remove the masking, you can easily see what's going on.
Let me show you.
It duplicates the linked pattern.
It's because I add the link pattern HTP here.
Then the program enters into the masking mode and adds the rest of the bytes as asterisks.
So how can I fix it?
Since I'm adding the link pattern again, I just need to jump over the link pattern like saw.
So the program will not add the link pattern to the buffer again, it will jump to the Byatt's right
after the link, Peter.
Cool.
Now with Prince, the link pattern on nuance, let me also enable the masking.
That's perfect, by the way.
I could also have created the buffer slides from the input text like so.
Since I'm opining to the buffer, I need to set its length to Zero Lexar, so the next opponent will
at the next bite, beginning from its first element, I can even do so.
It's still the same thing.
OK, that morant's.
As you can see, it still works, there is no significant difference between creating a buffer, using
the make function or doing it through the string to Bridezillas commercial.
They all are the same way of doing the same thing for both of the way go creates a new bridezillas with
a new back injury.
One small difference is actually that when you convert a string to a bachelor's go copy's all the bytes
of the strength to the less.
So the convert buffer has all the bytes of the string.
This means that I don't need to point to it.
I can simply change the bytes first.
Let's remove the resulting from here so that its length will be equal to the length of the input text.
Let me show you what the buffer contains.
I'm going to print it, then I'm going to be terminated from the program here.
As you can see, the buffer is an exact replica of the input string.
OK, let me take it back.
Here and here, I don't need to point to the buffer, as I said, the buffer already contains all the
bits of the string growthy.
So I'm going to comment about these.
Here, when the masking mold is enabled, I'm going to direct the set, the current part to the masking
character like SOL.
Limerence, as you can see, it still works perfectly.
So what type of solution depends on your taste and what kind of situation you are in?
All right.
That's so grown up in this program, you have used almost everything that you need to know for manipulating
strings, using bots.
OK, thank you for watching so far.
Seeing the next lecture by.