Skip to content
Advertisement

Javascript match for eslint

I am using match like this: text.match(v = /(d+.d+.d+.d+)/g). But When es-lint run it shows an error that v is not defined

I tried this: text.match(‘v = /(d+.d+.d+.d+)/g’)

But now match is not working.

Advertisement

Answer

It looks like you’re trying to do this:

const v = /(d+.d+.d+.d+)/g;
/* some kind of assignment = */ text.match(v);

but inline. You generally should not be assigning variables while you’re inside of a function call.

Advertisement