-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
  • 372
  • 1
  • 5
  • 20

1 Answers1

1

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

new RegExp("\\["+row+"\\]", 'g') 
Toto
  • 89,455
  • 62
  • 89
  • 125