Welcome back.
In this video, you'll learn how to create more complex patterns using regular expressions.
We'll look at grouping ranges and alternation constructs to build precise patterns for specific use
cases.
All right then let's check out w.
W will give me any word count.
Character and numbers are included.
So here it gives me all the numbers and all characters such as A, B, C, D, E and so on.
So here the whole alphabet is marked as well as all of my digits here.
As you can see as well, dots are not marked and slashes and those meta characters, those specific
characters, they are not marked as well and add neither.
All right.
If you want to have everything else, use capital W now if you want to have for example, the LA, let's
search for la la.
As you can see, I can search it with lowercase or uppercase in both cases.
My la la la la la.
Text here if you want to sing la la la la la la la la and so forth, then that's the one that is marked
here.
But as you can see, all of them are matching that pattern, even though I'm not using the literal capital
letter or not.
All right.
And if I would like to only have the ones that are bound to one specific side, I can go ahead and use
back or b l a.
And there you are.
So only the ones that have a boundary towards the left will now be displayed.
So which means that there's nothing before the law, or there is a white space before the law.
So only those ones will be marked.
So as you can see, this LA is not marked neither this one.
That's because the word boundary is not on the left hand side.
So let's go back to the snippets real quick and check out what we have here.
So we have character groups which we need to look at.
Then we have the negation sign.
So the anchors the match must start at the beginning of a string or line.
If you use that, then the double dollar sign a match must occur at the end of the string, or before
a next line at the end of the line of the string.
Pretty much.
All right then.
Yeah, let's check those ones out.
Let's go back to our sample file for example circumflex la.
And as you can see here, this one is marked.
So it's at the start of a string.
Let's go for an A.
As you can see here, there is the A at the beginning of the string.
Or if you want to have an M that's at the beginning of the string as well.
So there you are.
What if I want to have the one at the end of the string?
Well, the thing is that we have a whole text.
So this whole sample text file is one string, pretty much.
So if I want to have it at the end, as you can see, there is one character at the end of the string.
And that's this plus here.
So if I want to have the plus by the way, or the dot or any of those meta characters, I need to escape
those.
So if I search for them, I need to escape them.
And how can I escape them?
Well, I can escape them by using the backslash.
So backslash plus will give me the plus here.
As you can see the literal plus on the other side.
So if I just enter plus as you can see this plus will not be found.
And that is because it's a meta character and we need to escape them if we use regular expressions in
order to find them.
So backslash plus will give me the plus.
And as you can see this plus here is marked as well as the plus there.
But now if I only want to have the one at the end of a string.
And as I said, this whole text is one string.
I simply use the dollar sign.
And now you can see this plus is marked.
However, the plus here is not marked or not highlighted.
Now let's look at range real ranges real quick.
So as you can see we have this character group matches a single or any single character in a character
group.
By default the match is case sensitive, so character groups, let's check them out.
Let's go into our sample text, and in those square brackets I can go ahead and do something like A
to Z.
So now every single character between A and Z will be highlighted.
So as you can see all characters are highlighted.
If I only want to have a to F, as you can see, only A to F are highlighted and as you can see, it
doesn't care.
It takes capital letters as well as lower capital letters.
And so as you can see, our Visual Studio doesn't seem to care about this.
By default the match is case sensitive.
So in our case the character group was not case sensitive as you can see.
So it takes either.
All right.
But if you want to make sure and in other cases you need to use A to Z, for example, like that and
A to Z like that.
So they would have lower capital and upper capital letters pretty much.
All right.
So that's one group.
It's an example of a group.
We can use any letter in here.
So as you can see every single thing or every single letter that we put in there is marked as well now
or highlighted as well now.
So within this group, everything that is in the group will be highlighted.
Now we can create other ranges as well with digits.
So let's say I want to have every number number between 1 and 5.
There we are.
Now get all the numbers between 1 and 5 zero not included.
So 12345.
What if I want to have the opposite?
Well then I can use the circumflex again.
So circumflex 1 to 5 will give me all numbers except for one two, five.
So if I want to have every single number except for the seven, let's say, what would I enter?
All right, I have.
I hope you figured it out.
It's just circumflex seven.
All right.
Let's look at some practical examples in the next video.
See you there.