File size: 2,788 Bytes
33852e5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
1
00:00:00,000 --> 00:00:01,000
Hello team!

2
00:00:01,000 --> 00:00:04,000
Today we will review solution for coding exercises.

3
00:00:04,000 --> 00:00:07,000
Let's start from the first one pin number formatting.

4
00:00:08,000 --> 00:00:09,000
The solution is pretty simple.

5
00:00:10,000 --> 00:00:15,000
Do you remember that in demo for string formatting, I put examples of precision formatting at the bottom.

6
00:00:17,000 --> 00:00:21,000
Here also was an example about floating point number formatting.

7
00:00:21,000 --> 00:00:25,000
Basically, you can control number of places in your floating point number.

8
00:00:26,000 --> 00:00:27,000
And here is the solution.

9
00:00:27,000 --> 00:00:33,000
You are using specifiers to indicate that you want to format floating point number with scale of one.

10
00:00:34,000 --> 00:00:40,000
After that, you can use newline specifier if you wish, and format pin number again to have floating

11
00:00:40,000 --> 00:00:43,000
point number with scale of two, and so on.

12
00:00:43,000 --> 00:00:46,000
Here you can see results in console output.

13
00:00:47,000 --> 00:00:52,000
The second task ask user to enter text and split words.

14
00:00:52,000 --> 00:00:55,000
Hope you successfully learned regular expressions.

15
00:00:55,000 --> 00:00:59,000
Now you understand that you have different ways to implement this task.

16
00:00:59,000 --> 00:01:03,000
You can list all punctuation marks in regular expression.

17
00:01:03,000 --> 00:01:10,000
And you can use Posix basic regular expression Posix was developed by the Institute of Electrical and

18
00:01:10,000 --> 00:01:15,000
Electronics Engineers, mostly to provide backward compatibility with the traditional simple regular

19
00:01:15,000 --> 00:01:19,000
expressions syntax, providing a common standard.

20
00:01:19,000 --> 00:01:26,000
In Posix, we have different character classes and categories here in comments I listed for you Posix

21
00:01:26,000 --> 00:01:27,000
character classes.

22
00:01:28,000 --> 00:01:34,000
In our regular expression, we can use punctuation class and special character for all white spaces.

23
00:01:34,000 --> 00:01:40,000
Let's split our line in case punctuation marks or spaces will be found in the string one time or more

24
00:01:40,000 --> 00:01:41,000
times in a row.

25
00:01:42,000 --> 00:01:48,000
Let me run this program and I will enter any text here with different amount of spaces and punctuation

26
00:01:48,000 --> 00:01:49,000
marks.

27
00:01:53,000 --> 00:01:56,000
Pressing enter and here all words that I entered.

28
00:01:57,000 --> 00:01:58,000
That's all.

29
00:01:59,000 --> 00:02:02,000
Thank you for your attention and see you in the next lesson.

30
00:02:02,000 --> 00:02:03,000
Aethes.