2
vred
3y

You could use /\D+/.test('498934') == false to check if a string contains only digits. That statement will result to true. /\D+/.test('oijwei3') == false will result to false since the the test argument has letters in them.

Comments
  • 0
    You don’t really require \D+. \D should be enough.
  • 0
    @Voxera Ow, thats true. Thanks.
  • 2
    regexp are evil and should be banned ;p
  • 0
    @NoToJavaScript they are very powerful, and correctly used, very fast but once you go beyond the very simplest they get complex very fast also ;)

    And if you do not understand them you can end up with a performance black hole :)
Add Comment