-9

how to make regex for number from -100 to 100? Thanks in advance

Tom West
  • 387
  • 1
  • 3
  • 9
  • 5
    Is there a reason you want to use regex and not simple comparison like x < 100 && x > -100 ? – raphaelSeguin Dec 19 '18 at 10:51
  • [Regex number between 1 and 100](https://stackoverflow.com/questions/13473523/regex-number-between-1-and-100) Maybe help you – Mohammad Dec 19 '18 at 10:56
  • 2
    Please visit the [help], take the [tour] to see what and [ask]. Do some research, search for related topics on SO; if you get stuck, post a [mcve] of your attempt, noting input and expected output. – mplungjan Dec 19 '18 at 10:59

2 Answers2

0

You can use a regex range generator, such as http://gamon.webfactional.com/regexnumericrangegenerator/

I think this regular expression will do it:

/^-?([0-9]|[1-8][0-9]|9[0-9]|100)$/
Fred
  • 12,086
  • 7
  • 60
  • 83
-1

use https://regex101.com/ for checking your regex.

and use (?:\b|-)([1-9]{1,2}[0]?|100)\b expression to print numbers from -100 to 100