RegExp in JS plotly

In plotlyjs I find many instances of code like the following:

D=new RegExp("^rgb\\("+[E,E,E]+"\\)$")

This gives an error when loading, as I think it should, because this doesn’t look like a legal JavaScript RegExp expression, which would look like this:

D=new RegExp("^rgb\\("+E+','+E+','+E+"\\)$")

Can someone explain what I’m failing to understand about the plotly code? Thanks.

I corrected those RegExp statements to the form I showed in my note, and the errors I saw disappeared.