0

Given the following Regular Expression in JavaScript:

56\d.*

Above would match e.g. 45678. So my Question is: are digits in JavaScript chars?

*d Matches any single digit, . Matches any char except newline, * matches zero or more occurrences*

Stephan Kristyn
  • 15,015
  • 14
  • 88
  • 147

1 Answers1

3

Digits in JavaScripts, in a string context, are chars.

The dot in a Regular Expression matches every character, except for newlines. If you need a RegExp which matches every character, use [\S\s], which means "every non-whitespace character + every whitespace character" (=everything).

Rob W
  • 341,306
  • 83
  • 791
  • 678