-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
  • 352
  • 5
  • 18

1 Answers1

1

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

new RegExp("\\["+row+"\\]", 'g') 
Toto
  • 86,179
  • 61
  • 85
  • 118