Regex

Course
Time
1 hour 37 minutes
Difficulty
Beginner
CEU/CPE
2

Video Transcription

00:00
we'll come back to surgery. Introduction course heretics.
00:04
Let's continue where we left off
00:07
lesson for.
00:08
We'll go over length. Of course.
00:11
We already covered the Quanta fires.
00:14
There are a little bit more wild right, the serum or one or more for Sierra one,
00:20
for it is lost and will actually go over
00:23
when it's exactly a particular amount of characters or when it's a range of characters, right?
00:28
So this case again, it's much easier to explain
00:33
with numbers, but it can also be applied a words and later in the lesson, you will see the Woodwards.
00:39
But for now, let's start with numbers.
00:41
Now if I do dash plus, you can see
00:45
I'm detecting everything sort of frank.
00:48
And
00:49
in here you see two very familiar formats. Nine numbers are nine digits, right? Which is basically the same model numbers in a U. S. Social Security number.
01:00
Or you can see 16 digits down here, right, which is basically the secrets of a credit card.
01:06
Now
01:07
let's see, you want to pick on Lee one or the other. In this case, if you know, for example, that it's exactly
01:14
nine digits,
01:15
you can, for example, to do this right? And it would attack nine digits,
01:19
right? Or for a credit card, Right.
01:23
And then, for example, right to 16.
01:26
And then it takes 60. Unlike the capture,
01:29
uh, the brackets to score brackets. When you use these type of brackets,
01:34
you actually 10 minutes 10 0 you know, it's not 10 It means the actual number that you're trying to say.
01:42
No.
01:44
Okay, Kevin. So I understand that that the number, it's the amount of characters I want to see. Okay, So why do you have dashes and zeros? Well,
01:53
here's the thing. Right
01:55
or you're trying to find, Let's say, your Social Security number.
01:57
There might be several formats, right? And here's where we start adding up what we learned so far, right? So you know the first sequence of numbers. It's probably three numbers, right? And then you
02:08
there might or might not be a dash or
02:13
space. Now, if remember carefully correctly
02:16
Bassist flashes
02:20
and dash, you have to break in
02:22
again.
02:23
He used to let a question mark, which is 01
02:27
You can see it's starting to build itself that followed by that
02:30
gonna remember that
02:34
in the second set, menus to numbers. And again
02:38
just to cheat. You do the white space
02:42
and did or the dish.
02:44
You okay? It's making sense.
02:46
What about now? Well, something again right now. This time it's four digits, right? So
02:53
slash T right,
02:54
four digits.
02:57
All right.
02:59
And then this case, you go like, Oh, um
03:01
okay, I get it.
03:04
But at the end, there's no white spaces or nothing. Okay, if it's an email, you know,
03:07
you could, for example, imagine that. Okay, this is gonna be within an attachment. You actually
03:13
imagine this white space at the end, and you can do this, actually. And now you can see that
03:17
it does detect all three sequences and it detects none for the credit card. And again we're detecting. It's either
03:25
three digits followed by or not a space or eight ash, right toe digits
03:32
than two digits. Again, with or without the space for dash,
03:37
I followed by four digits, which is to form out of social your number and here to basically learn just now
03:44
the Red IX for detecting social security numbers.
03:47
Now, how does it work for carts? Credit cards? Then I feel like our cars a little bit easier.
03:53
It's a little more cheating issue if you want to call it that way.
03:55
Right? So let me
03:58
about a year face year
04:00
around, right? You know, the Carter, the credit card sequences four blocks off, four para tres four digits, Right?
04:06
So
04:08
Okay,
04:11
How does it work for us, then? Well, it's pretty simple. Literally. Copy pays this four times
04:16
there.
04:18
Simple.
04:19
Why? Four times to serve? Four blocks? Four characters. And it's always going to be four characters and again, either with or without dashes or white spaces. And here you just learned
04:32
Dad quickly had to build a tragic for a credit card detection.
04:38
Now let's say Oh, but what if it's a bank account number? Or let's say, Oh, what about it's Ah,
04:44
I don't know. My card has 10 digits. Instead, off 14 you're like, Okay, so how does that work? Well, you know, it's It's 36 months off, five
04:55
off. Whatever. You know, that's 15. Sorry. Uh
04:59
um
05:00
Great. So let's see, it's 15. Right? Is 3695 gets one.
05:05
How long you have to do?
05:09
Modified this little number here. Three seconds of five,
05:13
55 And guess What? What was that? Nothing meets, but neither wanted before. Five dash before five
05:18
for five years. He meets it,
05:21
so make sure you can literally copy face down
05:27
bm bam!
05:30
Are you gonna literally removal
05:33
and his sort?
05:36
Oh, Kevin. But it's still the victim. The one that thought off course it is cause this 555 with or without spaces and therefore he will detect them.
05:46
And again,
05:48
sometimes you might have false Pollock. That's something that might be realistic, right?
05:54
There are chances you're gonna find false positive. Again. There's a minimum of 10
06:00
15 detective here. And that's exactly what's here. 15. That's the reason this one in being detectives, because this one has nine.
06:06
Therefore,
06:09
not that much frequency. Now,
06:11
how about the phone number?
06:13
All right, how will we build one for a phone number? Right. So by us full number,
06:18
it's built with right
06:20
parentheses. Right?
06:25
Right.
06:27
And then you will say sometimes it's three numbers,
06:31
right?
06:33
You might
06:34
or might not have a space
06:38
again. You might or might not have to whisper and disease.
06:42
Okay.
06:44
And, uh,
06:46
race this and not confuse you. Right?
06:48
You have another three numbers, right?
06:50
home.
06:54
Do it. Ask you. Some people put in their formatting
06:59
and you have
07:00
three numbers. Sorry.
07:04
All right. Either
07:06
some people put
07:09
Dad,
07:10
some people leave a space,
07:13
and then you have an additional
07:17
four numbers.
07:18
And for
07:19
detection purposes, we're gonna put a space in there at the end,
07:23
Men. And there's a full number. Right? And you will be like phone.
07:30
Let's say it's
07:34
100
07:36
base.
07:39
123
07:41
please. 1234
07:44
Oh, Kevin, guess what? It didn't work. Oh, no. Why?
07:47
Well, let's see.
07:49
Three digits, right?
07:51
With
07:54
space
07:56
or dash
07:57
right
07:58
into the carcass broken,
08:01
and then you can see
08:03
everything looks perfect. So guess why it's not being detected.
08:07
Hint.
08:09
Like here?
08:11
Yep, You guessed correctly. Space.
08:16
So it was a tricky question, right? Tricking you.
08:20
But let's say it is the same thing again, right?
08:24
Uh,
08:28
let's say it. Hand Stashes. It doesn't have dashes
08:31
the fast basis.
08:35
It's broken because it
08:35
person made a typo because what still works. You could see still work while I was removing them. Regardless of where I start removing,
08:45
it's still gonna be working in this Casey.
08:48
It really doesn't matter. I can say for a couple of business
08:54
dash here. All right.
08:56
It will still follow the former again because your leader detecting for that space for dash here and here in the first segment, you also turn to take that closing bracket and beginning you turn to take if it's opened, Doesn't matter. Right? So now you know how
09:13
these work, right? You have to actually build three rabbits is so far in this lesson,
09:18
and there's more to come.

Up Next

Regex

In this course you'll learn the basics of regular expressions, also known as Regex. As a professional you will understand when it is beneficial to use Regex and when it's not, how to construct Regex, and how to read Regex built by other professionals.

Instructed By

Instructor Profile Image
Kevin Hernandez
Instructor