WEBVTT 00:00.330 --> 00:01.230 Welcome back. 00:01.700 --> 00:06.660 The last lecture we have detected, the links inside the input text in this lecture. 00:06.880 --> 00:08.370 We're going to mask links. 00:09.060 --> 00:13.590 When the program detects the link, it should mask the link until the link. 00:13.590 --> 00:19.070 And to do that, we need to know whether we are inside of a link or not. 00:19.590 --> 00:25.980 I will use a bool variable to keep track of it and I'm going to enable it here whenever we are inside 00:25.980 --> 00:26.520 of a link. 00:29.050 --> 00:32.860 Here we are adding everybody from the input to the buffer. 00:33.430 --> 00:38.730 However, while we are inside of a link, we should only add the masking character instead. 00:39.040 --> 00:42.020 So the link will be replaced by the masking character. 00:42.700 --> 00:44.770 Let me cut the current byte form here. 00:45.070 --> 00:46.830 Let me replace it with this. 00:47.350 --> 00:51.670 And lastly, let me assign the current budget to a new variable like this. 00:52.320 --> 00:54.860 OK, after this small refactoring. 00:54.940 --> 00:57.880 Now I'm ready to mask the current bytes here. 00:57.910 --> 01:03.610 I'm going to set the current pipe to the mass character, and I'm only going to do so if we are inside 01:03.610 --> 01:04.150 of a link. 01:07.980 --> 01:13.230 By the way, while in here, let's put this Maskin character into a constant Lexar. 01:15.110 --> 01:17.990 Here, let's assign the mass constant instead. 01:19.320 --> 01:21.920 By the way, the mask is a single character, right? 01:22.620 --> 01:26.190 That's why I put it in a room, literal instead of a string. 01:26.520 --> 01:29.550 This is more efficient because it is just a number. 01:30.370 --> 01:31.830 Here's a tip for you. 01:32.640 --> 01:37.080 When you are working with whites, continue working with whites. 01:37.440 --> 01:43.020 Do not convert a string to a bachelor's or a bachelor's to a string on this necessary. 01:43.300 --> 01:49.650 I prefer to work with whites mostly because they are more efficient and used everywhere in Go Standard 01:49.650 --> 01:50.160 Library. 01:50.970 --> 01:52.170 OK, let me try it. 01:53.410 --> 02:00.910 Cool, now when it sees a link, it masks it, however, there is a problem, it also masks the rest 02:00.910 --> 02:01.640 of the input. 02:02.230 --> 02:07.810 So this leads us to our next goal, stop masking when white space is detected. 02:08.770 --> 02:15.040 OK, for now, let's pause the link pattern, and whenever we see one of the whitespace characters, 02:15.040 --> 02:21.430 such as a space or a new line and so on, to do that, I'm going to use a switch statement like so. 02:24.190 --> 02:30.110 And when I did that white space, I'm going to stop the masking by setting the invariable to false. 02:30.610 --> 02:34.300 So the program will know that it's not inside of a link anymore. 02:34.510 --> 02:36.490 OK, let's run it. 02:38.200 --> 02:44.440 Cool, now it only masks the link, not the rest of the input text, that was easy, right? 02:44.950 --> 02:51.430 OK, let's check out our last call, Puttan, HDP prefix in front of the masked link. 02:51.790 --> 02:53.240 I can do that very easily. 02:53.650 --> 02:56.710 I'm just going to expand the link to the buffer, so. 02:57.790 --> 03:03.670 This is a special case for the apan function, you can append a string to a bachelor's by adding three. 03:03.670 --> 03:11.250 That's after the string value like so here it opens the bytes of the links, string the buff by slice. 03:11.950 --> 03:13.060 OK, let's try it. 03:14.320 --> 03:19.150 Cool, as you can see, it's first Prince staged perfect, then it masks the link. 03:20.030 --> 03:23.400 However, there is one little problem here in the input link. 03:23.410 --> 03:27.900 There are eight characters, but the program prints 15 stars instead. 03:28.450 --> 03:29.590 Why does it do so? 03:30.280 --> 03:33.610 If I remove the masking, you can easily see what's going on. 03:33.700 --> 03:34.450 Let me show you. 03:35.050 --> 03:36.860 It duplicates the linked pattern. 03:37.390 --> 03:40.900 It's because I add the link pattern HTP here. 03:41.470 --> 03:47.200 Then the program enters into the masking mode and adds the rest of the bytes as asterisks. 03:48.010 --> 03:49.330 So how can I fix it? 03:49.840 --> 03:55.060 Since I'm adding the link pattern again, I just need to jump over the link pattern like saw. 03:56.140 --> 04:02.020 So the program will not add the link pattern to the buffer again, it will jump to the Byatt's right 04:02.020 --> 04:03.100 after the link, Peter. 04:04.320 --> 04:04.720 Cool. 04:04.890 --> 04:09.720 Now with Prince, the link pattern on nuance, let me also enable the masking. 04:11.410 --> 04:13.160 That's perfect, by the way. 04:13.210 --> 04:17.440 I could also have created the buffer slides from the input text like so. 04:18.690 --> 04:24.960 Since I'm opining to the buffer, I need to set its length to Zero Lexar, so the next opponent will 04:24.960 --> 04:29.220 at the next bite, beginning from its first element, I can even do so. 04:29.610 --> 04:30.750 It's still the same thing. 04:31.610 --> 04:32.810 OK, that morant's. 04:33.990 --> 04:39.600 As you can see, it still works, there is no significant difference between creating a buffer, using 04:39.600 --> 04:43.270 the make function or doing it through the string to Bridezillas commercial. 04:43.800 --> 04:50.790 They all are the same way of doing the same thing for both of the way go creates a new bridezillas with 04:50.790 --> 04:51.750 a new back injury. 04:51.990 --> 04:58.620 One small difference is actually that when you convert a string to a bachelor's go copy's all the bytes 04:58.620 --> 05:00.260 of the strength to the less. 05:00.780 --> 05:03.960 So the convert buffer has all the bytes of the string. 05:04.500 --> 05:07.140 This means that I don't need to point to it. 05:07.590 --> 05:10.260 I can simply change the bytes first. 05:10.260 --> 05:16.200 Let's remove the resulting from here so that its length will be equal to the length of the input text. 05:16.680 --> 05:18.940 Let me show you what the buffer contains. 05:19.200 --> 05:22.620 I'm going to print it, then I'm going to be terminated from the program here. 05:27.280 --> 05:31.180 As you can see, the buffer is an exact replica of the input string. 05:32.910 --> 05:34.280 OK, let me take it back. 05:36.330 --> 05:42.060 Here and here, I don't need to point to the buffer, as I said, the buffer already contains all the 05:42.060 --> 05:43.260 bits of the string growthy. 05:43.920 --> 05:45.420 So I'm going to comment about these. 05:46.710 --> 05:51.660 Here, when the masking mold is enabled, I'm going to direct the set, the current part to the masking 05:51.660 --> 05:52.680 character like SOL. 05:54.410 --> 05:57.840 Limerence, as you can see, it still works perfectly. 05:59.550 --> 06:04.830 So what type of solution depends on your taste and what kind of situation you are in? 06:05.520 --> 06:06.000 All right. 06:06.000 --> 06:10.950 That's so grown up in this program, you have used almost everything that you need to know for manipulating 06:10.950 --> 06:12.380 strings, using bots. 06:12.900 --> 06:15.000 OK, thank you for watching so far. 06:15.150 --> 06:16.440 Seeing the next lecture by.