Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Exercise: Regexes part 2

Write functions that returns true if the given value is a

  • Hexadecimal number
  • Octal number
  • Binary number

Write a function that given a string it return true if the string is a number. As there might be several definitions of what is the number create several solutions one for each definition:

  • Non negative integer.
  • Integer. (Will you also allow + in front of the number or only - ?
  • Real number. (Do you allow .3 ? What about 2. ?
  • In scientific notation. (something like this: 2.123e4 )
23
2.3
2.3.4
2.4e3
abc