1
00:00:00,300 --> 00:00:08,100
In this video, you learn how to extract text that contains numbers for this example, we'll work on

2
00:00:08,100 --> 00:00:08,460
this.

3
00:00:08,460 --> 00:00:13,800
I piece the text file that I have in here and you can find this untouched in the lecture resources.

4
00:00:14,490 --> 00:00:17,970
So we have IP addresses in this text file.

5
00:00:18,360 --> 00:00:30,390
Our purpose is to extract only those IP addresses that start with 12 in the third part of the IP address.

6
00:00:30,630 --> 00:00:33,780
So that's the first, both the second and the third part.

7
00:00:34,050 --> 00:00:35,310
This starts with the 12th.

8
00:00:35,460 --> 00:00:37,950
The first one also starts with 12.

9
00:00:38,280 --> 00:00:42,980
So we want this and that's let's build the codes for that.

10
00:00:44,270 --> 00:00:52,610
With open eyepiece that you see in reading modes as file, we load the contents in a content variable

11
00:00:52,730 --> 00:00:54,200
using file that reads.

12
00:00:59,360 --> 00:01:02,990
So that is the contents in a variable now.

13
00:01:05,420 --> 00:01:12,380
We built the pattern, which is our readers compile with numbers now.

14
00:01:12,890 --> 00:01:15,140
We use a number range.

15
00:01:15,350 --> 00:01:19,760
So we want the first part, which could be any number.

16
00:01:20,280 --> 00:01:25,970
That means you want to use square brackets and use a number range.

17
00:01:26,240 --> 00:01:29,240
So we have digits from zero to nine.

18
00:01:30,440 --> 00:01:30,780
Right.

19
00:01:31,130 --> 00:01:36,020
And we want to match three times of three digits.

20
00:01:36,680 --> 00:01:43,460
That means we could have one digits from zero to nine two digits three digits maximum.

21
00:01:44,540 --> 00:01:50,300
Don't try to match more than that's because after that, we want to match a dots.

22
00:01:50,600 --> 00:01:57,410
So backslash dot actually, because adults is a special character, so we need two escapees with backslash.

23
00:01:57,770 --> 00:02:01,800
Then we have more ranges from zero to nine.

24
00:02:01,900 --> 00:02:08,539
Again, three times because every part of the IP address has three numbers.

25
00:02:08,810 --> 00:02:12,930
Again, backslash dot, we only want 12.

26
00:02:12,950 --> 00:02:17,860
So this time this would be a literal character.

27
00:02:17,870 --> 00:02:19,430
It's a one and two.

28
00:02:19,920 --> 00:02:22,760
Then after that, we could have any number.

29
00:02:22,790 --> 00:02:32,450
So again, the third number of this third part of the IP address could be anything from zero to nine.

30
00:02:32,720 --> 00:02:34,040
And we want to match it.

31
00:02:34,580 --> 00:02:35,090
Three.

32
00:02:35,330 --> 00:02:36,890
Sorry, one time only.

33
00:02:37,550 --> 00:02:39,620
So there's only one number after that.

34
00:02:40,100 --> 00:02:49,070
Then we have backslash dot and then the last parts could be again, anything so zero, two nine, three

35
00:02:49,250 --> 00:02:50,240
times.

36
00:02:51,740 --> 00:02:52,430
That's it.

37
00:02:53,750 --> 00:03:01,790
Matches are equal to pattern dot finds all content.

38
00:03:04,060 --> 00:03:06,900
And let's call them here, executes.

39
00:03:07,870 --> 00:03:13,990
And this is the output, so it's a list of two items and we have this item, which starts with 12 in

40
00:03:13,990 --> 00:03:18,010
the third part and the other IP address again, starting with 12.

41
00:03:18,910 --> 00:03:26,710
So simple and clear, that's how you would work with numeric texts such as IP addresses.

42
00:03:26,950 --> 00:03:29,860
I'll talk to you in the next video with some more examples.

