Hello, in this JavaScript video, I am going to demonstrate can you think or I'm going to demonstrate, I'm going to demonstrate the regular expression object, the regex. So if you don't know what reg x's are, where regular expressions are, they essentially taking a string, and they aligned to manipulate them. So you could filter them maybe swap words around. And that's what we'll do because so many other features that you could do, you could check for a pattern. So the great if you want to check if a string is a valid email type, you know, read get online to check if it's an actual valid email, just that the format is a valid email, a bunch of other things that you can check as well. You could string together a bunch of different you know, conditions like oh, you left out four spaces and two s's in there, and you're free of errors on one of these in this all you could do on a check.
Morrow do is provide the Mozilla Developer Network link for regex. So you can see all the different properties. I'll also provide one more link, which will essentially allow you to generate your own regular expressions because generally speaking, basic ones, they're okay to make yourself otherwise your use generator is just too cumbersome to try and make an appeal. So, okay, so first of all, a couple different ways you can create it, you can use the new keyword to create it. Or you could just, you know, so many to a regular variable and JavaScript knows what you're doing. And we'll go down that route, or provide lots of the Mozilla Developer Network link and Darryl have both methods on there.
So I'll call this already for regular expression equals four slash backslash w Sorry, that was it. And Pardon me. Just please, the same as two words ominous warning At Moran, again the format is cumbersome. So I would highly recommend using a generator but let's demonstrate how this would work. Let's call this string equal john smith. I know john wrong, but what what you're gonna do about it.
So let's say var equals string dot replace. And I need to say, minus instead of an equals string dot replace, you provide your regular expression for R in this case. dollar one, so dollar one and two just represent the words. So this is done to this $1 one. And in this format, there'll be swapped around, and there'll be a comma between that if we just do console log Though refresh, as you can see, what I'm, you know, gonna do I want to go a step further and just put a console dot log here. Oh, no.
So you can see that's the original string. That's the new resulting string after we stopped your room and inserted a comma. That's it for regular expressions. If you have any questions, feel free to shoot me a message or provide all of those amazing links as well as an extra task, you know, feel free to go over those links. That is one of the tasks but as a further test, we're going to do we've got you know, Smith first and Carmen and Jay Cohen, Giacomo, how you pronounce your name. It could be some sort of, you know, Swedish name, Russian name, making simple appear.
Okay, so we've got second word, comma, first. The wrong way to do the second word comma two, comma, second word, comma. second word again, no try and create that format. So that's it. Thanks for watching. I look forward to seeing you in the next video.