Question about RegExp

Another example:

image

Do you see the problem here? ^

This is fundamentally the same example as you used before. The previous caveat about escaping characters still applies.

not really, that’s just general escaping rules for strings, you are just showing how strings work

image

That’s a big difference.

You can’t say

let re = new RegExp(<a>, <b>);
it creates a regular expression like /<a>/<b>

You literally have to double escape every special character with RegExp for your statement to be true.

But I’m done with making my point.

At this point it’s already been agreed that escaping characters is required. I am not sure why you are arguing anymore.

I have added the note you think is necessary

and <a> and <b> don’t want to be literals, they are just placeholders to show where the stuff you put in new RegExp will appear in the formed regex
Do you think I should add a note also about this?
Or how else should I write this to not have ambiguities?

ieahleen you clearly know how to program & I’ve seen several of your posts on this site that are spot on. We all have a responsibility to correct one another to make us all better versions of ourselves. I am no exception to rule.

I get the point you’re trying to make to help beginners visualize the similarities of the two. I think if you simply add remember to double escape all special characters you’ll be fine.

I always strongly suggest using the literal notation because it’s created at compilation time whereas the RegExp is created at run-time which is significantly slower. I get it that this is likely out of the scope of many of the newer readers.

As programmers you have to be able to read material and not get bogged down on things you don’t understand. Just make mental note of it. I say this comment not directly to you but to any programmer who has possibly finished all the FCC material and who can still benefit from these forums. I contribute to boards to inform on best practices and what’s being used in live sites now.

1 Like

How long have you been practicing coding and how long did it take you to become a master? Im 20 and have been practicing a couple months. Hoping to become a master at some point.

Btw I understood your explanations the best for this specific thread so thank you and thanks to everyone else.

You never become a master at coding because there is always more to learn and your knowledge keeps going out of date. But how much time you need to feel like you have a strong grasp of the languages, tools, best practices, etc varies but will take many years.

1 Like

I agree with @JeremyLT. You can never truly become a master at coding, because there is always going to be a flaw in your code. There is always something new to learn. Especially JavaScript, with the release of new EcmaScripts every year, there will ALWAYS be something new to learn.

I still don’t understand why this topic is still active. It’s solved. new RegExp is the same with the literal term. The one difference is that RegExp is in string notation. That means you have to escape some characters. But it doesn’t change the fact that it’s still the same thing. It does the same thing, just in different notation. Just because you have to escape, doesn’t mean it’s not the same.

1 Like

Four years professionally. No college degree in computer science.

I’ve been laughed at in interviews, rejected numerous times, failed on board problems, 100s of applications with no replies. I’ve been fired 3 times by 3 different companies for under performing and I still keep the letters as motivation.

But I didn’t quit & after changing how I approach life and maximizing my time each day to complete my goals I’ve made progress. Of course I had to make sacrifices along the way… but I view life with a different lens than when I was younger.

Currently I am the senior developer at my company. Not an easy road, but that’s another story.

My suggestions as to how to live your life will run perpendicular to everyone else on this forum; but, each day I set goals on a white board and do everything in my power to complete them. That meant sacrificing social life and not wasting time doing other things that did not contribute to my goals.

20 is young; but, life goes by faster and faster the older you get. You don’t have to take it as serious as me & you’re probably not expecting my in-depth reply, but if you remember anything I say in this:

Never believe you CANT do something. You really can do anything. Test the boundaries, ruffle the feathers. All the things you learn now at your age, you’ll rely on later in life. And the shortcuts you take now,. you’ll regret it later when you’re older.

2 Likes

I have closed this topic, to prevent conversation from veering, and being heated.

2 Likes