1
00:00:00,270 --> 00:00:06,330
Another task with the Dome event can be like this split each new sentence to a separate line in the

2
00:00:06,330 --> 00:00:11,850
paragraph text, a sentence can be assumed to be a string of text terminated with a period.

3
00:00:12,120 --> 00:00:16,890
And actually, we have exactly the same text and paragraph, just like we did previously.

4
00:00:17,130 --> 00:00:19,770
Now the question is how we can implement this task.

5
00:00:23,130 --> 00:00:25,620
And actually, one might think, okay, we have, period.

6
00:00:25,770 --> 00:00:27,750
We can simply split it by period.

7
00:00:28,050 --> 00:00:29,060
Let's try this out.

8
00:00:29,070 --> 00:00:36,030
First of all, I want to find here our paragraph with document quote a selector p just like we did previously.

9
00:00:36,240 --> 00:00:42,420
And now here we can write paragraph dot inestimable equals paragraph dot image HTML.

10
00:00:42,570 --> 00:00:44,580
And we want to split it with DOT.

11
00:00:44,940 --> 00:00:50,790
And let's check what we will have in this case after we split it and we have an array of our strings,

12
00:00:51,000 --> 00:00:52,560
we must join it back.

13
00:00:52,830 --> 00:00:58,070
But in this case, we want to put here, first of all, DOD because we're joined in and by DOD.

14
00:00:58,080 --> 00:01:02,700
But then we need a close tag for our and open tech for our own U.P.

15
00:01:02,880 --> 00:01:08,940
In this case, were writing paragraphs for every single line and join is not applied to the last element.

16
00:01:08,970 --> 00:01:14,050
This is why at the end we want to write plays and whoever must close our additional team.

17
00:01:14,340 --> 00:01:16,330
Let's check the salt overload in the page.

18
00:01:16,530 --> 00:01:19,440
And actually, it is working, but only partially.

19
00:01:19,680 --> 00:01:25,320
Yes, it is working for the simple sentences, but it won't work for the sentences where we have two

20
00:01:25,320 --> 00:01:26,910
or three dots, for example.

21
00:01:26,910 --> 00:01:30,000
As you can see here, we have lines with one dot on it.

22
00:01:30,150 --> 00:01:35,160
And this is exactly the problem, because here we split it just by one dot and this is Ron button.

23
00:01:35,190 --> 00:01:36,810
Total, our logic is correct.

24
00:01:36,990 --> 00:01:43,170
We can expect our STEM elements as you can see, they are prepped correctly, wispy and then were close

25
00:01:43,170 --> 00:01:44,550
in our last picture.

26
00:01:44,850 --> 00:01:48,510
So it is working, but split by a dot is not our case.

27
00:01:48,810 --> 00:01:51,750
And actually, here were coming to regular expressions.

28
00:01:51,840 --> 00:01:56,460
And this is some knowledge that you must learn, at least on the basic level, because you will use

29
00:01:56,460 --> 00:02:01,440
it in a lot of cases when you are working, for example, with strings and to try and check regular

30
00:02:01,440 --> 00:02:02,080
expression.

31
00:02:02,100 --> 00:02:05,670
I highly recommend you to use the website at of dot com.

32
00:02:05,730 --> 00:02:06,900
It is completely free.

33
00:02:06,990 --> 00:02:11,850
You can find another websites, but here it is really nice to see what we will find.

34
00:02:12,180 --> 00:02:15,150
And as you can see here, you can write a regular expression.

35
00:02:15,360 --> 00:02:18,870
And here you can provide the text and check how it will work.

36
00:02:19,140 --> 00:02:24,180
Also here on the right, you can set some flags, for example, multi-line global and so on.

37
00:02:24,630 --> 00:02:29,490
As you can see, this is the regular expression that we want to write, and when I'm hovering on this

38
00:02:29,490 --> 00:02:32,640
symbols, it will show you what exactly we are doing here.

39
00:02:32,850 --> 00:02:37,860
So this is the beginning of regular expression and we are prepping regular expression, always with

40
00:02:37,860 --> 00:02:38,550
two slashes.

41
00:02:38,790 --> 00:02:43,860
So this left at the beginning and ended the end is just a start and end of the regular expression.

42
00:02:44,130 --> 00:02:49,840
Now here inside we have Dot, but Dot is a special symbol inside regular expression.

43
00:02:49,860 --> 00:02:52,650
This is why we must escape it with the backslash.

44
00:02:52,770 --> 00:02:56,040
As you can see here, this is just matches a dot character.

45
00:02:56,130 --> 00:02:57,780
Now here we have square brackets.

46
00:02:57,930 --> 00:03:04,200
And as you can see, everything inside square brackets is negated set, which actually means this must

47
00:03:04,200 --> 00:03:05,130
not be there.

48
00:03:05,490 --> 00:03:08,700
And this current symbol is the start of our set.

49
00:03:08,940 --> 00:03:11,490
And here we have dot and open tech.

50
00:03:11,760 --> 00:03:16,350
In this case, we're looking only for a single dot, but not for several dots.

51
00:03:16,380 --> 00:03:18,510
This is everything that we want to see here.

52
00:03:18,750 --> 00:03:21,690
And as you can see here in our code, it is working correctly.

53
00:03:21,840 --> 00:03:24,870
And now we have this matches on only with a single dot.

54
00:03:25,080 --> 00:03:30,330
As you can see here, we have three dots button with the last two will be checked because we're interested

55
00:03:30,330 --> 00:03:31,410
only in Dot one.

56
00:03:31,410 --> 00:03:33,750
We don't have the second dot afterwards.

57
00:03:34,050 --> 00:03:39,090
This is where we can copy paste this regular expression and just put it inside our split.

58
00:03:39,450 --> 00:03:42,630
And here I must write less at the beginning and end at the end.

59
00:03:42,840 --> 00:03:48,330
And this is our regular expression, and I totally understand if you don't get 100 percent what I'm

60
00:03:48,330 --> 00:03:53,910
doing here because you must learn some basics of regular expressions first, but they're extremely important

61
00:03:53,910 --> 00:03:55,710
for you if you're working with strings.

62
00:03:55,800 --> 00:03:57,870
Now let's check in for this code is working.

63
00:03:58,110 --> 00:03:58,800
So here I am.

64
00:03:58,800 --> 00:04:00,810
Jump into our page and reload in it.

65
00:04:00,960 --> 00:04:02,730
And now it is working correctly.

66
00:04:02,940 --> 00:04:08,850
We made our split, and here, for example, three dots are still there and this is the single sentence.

67
00:04:09,000 --> 00:04:14,700
And when we have a 1.0, then we simply consider the split and then we move this text on the next line.

68
00:04:14,850 --> 00:04:20,250
And actually, regular expression knowledge is a little bit outside of JavaScript, but you will still

69
00:04:20,250 --> 00:04:21,060
use it a lot.

70
00:04:21,330 --> 00:04:26,490
But also, if you will learn regular expressions, you cannot use them in every single language because

71
00:04:26,490 --> 00:04:28,770
in all languages, it is exactly the same.
