-1

Overall Goal: I would like to be able to capture a positive or negative number that looks something like this: xxx.xxx

I am also using Google Sheets, so I cannot use any lookarounds

Example Criteria:

  • +123.123 ---> 123.123

  • +30% ---> 30

  • +4% ---> 4

  • -1% ---> -1

  • 0 ---> 0

  • +12 ---> 12

  • -3 ---> -3

What I've Tried:

The main regex I've been using is: -?\d+.?\d*. The problem with this one is that it also captures the percent signs, which I do not want. Percent signs seem to be considered part of the number.

I've also tried: -?\d+.?\d+. This one runs to the problem of not capturing single digit numbers.

1 Answers1

0

. matches any character (Google uses RE2). You should escape it.

-?\d+\.?\d*
Diego
  • 9,261
  • 2
  • 19
  • 33