RegExp symbols for variables and substitution


Hello camp!

In the fourth solution, the symbol (`) was used. I made my own decision and tried to start with RegExp, but I could not remember how to make a search set using a variable. I spent the whole day searching, but I only came across the use of pure variables / strings, without square brackets around.
When I looked at the 4th solution, it seemed to me that somewhere in the RegExp lessons I had already seen such a syntax, but even then I could not find this lesson, if it exists, I would be glad to have a link or a link to another source explaining this syntax.

Also, I couldn’t find a lesson where () were used in a literal RegExp, it seems to me that this was also related to substitution, I would be grateful for the link.

Also surprised by the possibility of using square brackets with a variable in this post:

As far as I understand, this syntax is interpreted as a Symbol Class designation, if so, I would like to know what other syntaxes can be used in a similar implementation (“,” + var + “…”, flags).

Thank you for attention!

Yes, I re-read this article many times, but only at the end there is an example of using an apostrophe, without any explanation. Also open is the question of freecodecamp tutorials that touch on this syntax. There is very little information in the article you sent about using the RegExp constructor. It was extremely difficult for me to find information about the use of functions in RegExp constructors. The syntax of the RegExp constructor is generally little covered on the net, I understand, of course, that it is similar to the literal syntax, but there are still differences.

Thanks for the link to the discussion, there was just about Template Literals in the last post (as in the 4th solution). This is what I lost, it turns out that this was in the ES6 lesson cycle. Indeed, quotes were used in your solution, but I was interested in both syntax with quotes and with Template Literals. In any case, thanks for the reply.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.