1
var values = divStyle.match( /-?[\d\.]+/g );

The above code is giving me an error when I run yarn build.

error: unnecessary escape character: \. no-useless-escape

How do I fix this?

tk421
  • 5,775
  • 6
  • 23
  • 34
LTech
  • 1,677
  • 5
  • 29
  • 48

1 Answers1

1

As already answered here: Does a dot have to be escaped in a character class (square brackets) of a regular expression?

In a character class (square brackets) any character except ^, -, ] or \ is a literal.

So in your case simply do not escape the dot:

var values = divStyle.match( /-?[\d.]+/g );
Sebastian Kaczmarek
  • 8,120
  • 4
  • 20
  • 38
  • thank you, that worked. I didn't understand the issue enough to connect it to the other question. – LTech Mar 28 '19 at 09:12