 Okay, this tutorial once again is part of a series and it's going to be kind of adding on to Something we kind of work with before we have looked at replacing Alphanumeric characters here's an example. Okay, so oh and by the way, this is a series There should be an annotation on screen to the full playlist. I recommend watching the full playlist This is our file that we've been working with It's got some special characters in here letters numbers lowercase uppercase is just a random file created for this tutorial I can say said and Then I can say that I want to substitute everything so we're gonna say substitute and this means all instances inside our text file and Let's say we want to substitute all numbers. We can say 0-9 inside our square brackets here regular expressions saying look for any number 0 through 9 and We can replace them with an asterisk So there you can see all our Numbers are now asterisks now we could go and as we said a Through z will replace all lowercase and if we do capital a through lowercase c it'll do all Characters replacing them another way to do that. It's kind of just another way to do the same thing Although you'll notice that in this it's not it's replacing in this instance all alpha Characters all alphabetical characters both lowercase and uppercase it's not getting the spaces It's not getting special characters outside of the alphabet like forward slashes or if there were other types of punctuation So let's say I wanted to modify everything that is not a number What we can do is we can say Before we said this is number well now we can say with a carrot symbol inside our square brackets But right before our zero through nine. It's saying find everything that's not a Zero through nine and replace it with an asterisk so this time we have just our numbers left We don't have any other punctuation respect special characters Spaces forward slashes like I said question marks exclamation marks periods Other stuff like that if it's not a number then we're replacing it So that's what this asterisk means inside our brackets for our regular expression saying look at all numbers anything That's not that replace with an asterisk and of course we could do the same thing but with alphabetical letters So here we can say a through z once again this lowercase So everything that's not a lowercase letter so even our uppercase letters Which our t's are still asterisk and again we can go capital a through lowercase z for all alphabetical now with that let's say we wanted to Replace all everything that's not alphan numeric. Well if I can remember Was it zero through z? So yes that way it worked this replaced All our spaces all our forward slashes and the other special it did not replace our backslash once again backslash Backslashes are a little bit special Because we're working with said now we should I Was gonna say something we should be able to and I haven't tested this is another one of those I'm gonna try something out and it may not work and if it doesn't I might just move on Well, let me give you another example before I go into that and then we'll try to remove that backslash using the same little setup But let's say we wanted to replace everything All these alphan numeric characters so this would be replace all alphan numeric characters and Spaces I should be able to do a space there. Nope that did not work. So I might have to backslash that Okay Confusing myself here. Oh, I'm an idiot. Okay. This is what I'm doing wrong Inside our square brackets. So what I just did by accident because I put this in the wrong spot. I was saying find a single alphan numeric character and spaces and replace them so So yeah, that's Let's let's try doing this. Let me try this. Let me put a space here. Okay. That's what I was originally trying to do So within our square brackets We're saying find anything that's alphan numerical or a space. I can also do Alphan numerical and a well Let's see our forward slash here. Okay, as long as I guess as long as it's inside a regular expression It's okay. It's saying, okay, good We're replacing everything that is alphan numeric or a forward slash and I could do or a forward slash in space Which is everything in our file, but if we had question marks or other special characters in there They would not be affected. So let's actually do that. Let's go Vim text go in here. Let me put a question mark here a period here and Just for fun. Let's put This is inside parentheses or square brackets there And we'll play with that later on So here if we do that same command again, you'll see that our period is not changed now You will notice our question mark I was wrong about the question mark and I think that's because of the way I did this Because this is once again looking at an ASCII chart and going from zero through lowercase c So a question mark falls into that if I was to do this nine and then I'll say Capital a through capital z and lowercase c through lowercase c Backslashes in spaces this should get everything that is alphan numeric a backslash or sorry forward slash or space But I don't think it will get our question mark and our other special characters. Okay, so that is important I did show this in a previous tutorial Maybe I'll go back and annotate it that that does work in general But it is still different than this So all depending on what you're trying to do So I'm glad I realized that because I knew that this worked I didn't realize that it was different than this and that does make sense because it is going on an ASCII chart from this character to this character and Punctuation does fall in that category So let's say we did want to replace our brackets though So let's say we want to replace all numbers and Our brackets so we have our brackets here We can do that we can go a Bracket here and that works and If I put a bracket there that doesn't work because it's thinking that we're closing off our regular expression here so What you would want to do is put it here There you go Wait, yeah, that did work. Okay Yeah, it's a little confusing and and I'm trying to not get confused while I'm giving tutorial So maybe I threw too much at you today. I hope I didn't but it's a video so you can always rewind But let's try to review just a little bit We started off with this this this is saying replace all No, I'm sorry this is saying replace all numbers this is saying replace everything but numbers so punctuation spaces special characters that sort of thing this would be replace all Lowercase everything but lowercase letters. This would be replace all uppercase letters Now if we were to do I'm sorry everything but uppercase letters We can say this replace everything but alphabetical letters and of course as I said before you could do This but it's not exactly the same It's it's a little different in in what it's covering but depending on what you're doing it may or may not work So that that's First little look right there is is the let's replace everything but that that's where that carrot symbols. It means there We can also say everything but Let's go back up on everything but alphabetical letters and spaces or everything but I'm sorry alphabetical characters and backslashes or alphabetical characters and forward slashes And you can do backslashes and forward slashes because we're inside our square brackets here saying regular expression It's not thinking it's part of the said command. It's kind of saying okay It's kind of like please excuse my dear aunt Sally, you know, it's it's looking at different things in different orders It's going okay. Let's figure out what all this is and then we put that in here So said is not looking at these back slashes and forward slashes really It's it's generating something else that it's reading if you want to think about it like that That's how I think about it. Anyway So regular expressions you can add other stuff in there now so This at the beginning of that means Everything but these so this would replace all those things And again, if I put a space inside our square bracket here would include those spaces So again, I think I might have thrown a little too much at you today I kind of reviewed a little bit there at the end It's a video watch it a few times and I thank you for watching Please be sure to check out the annotation which will link you to the entire playlist of this video if you haven't already Also check out my website films by Chris calm That's Chris the K there should be a link in the description and I hope that you have a great day