-1

I'm trying to use this regex pattern to match this value [1] When I use this regex:

new RegExp("\\["+row+"\\]/g") 

it returns me this:

/\[1\]\/g/

instead of this:

/\[1\]/g

I have tried many things but nothing works apparently.

Some help would be appreciated.

Iason
  • 342
  • 3
  • 16

1 Answers1

1

Don't put the regex delimiter when you're using the constructor:

new RegExp("\\["+row+"\\]", 'g') 
Toto
  • 83,193
  • 59
  • 77
  • 109