I have a problem. I should count how many digits are in date. For example I have date 13/13/2013 and I need to count these 8 digits. Does anyone know?
Asked
Active
Viewed 39 times
-3
-
Does this answer your question? [Count the number of integers in a string](https://stackoverflow.com/questions/7657824/count-the-number-of-integers-in-a-string) – Mar 14 '21 at 19:49
-
'13/13/2013'.length - 2 – Steve Tomlin Mar 14 '21 at 20:02
1 Answers
0
Try this:
const date = '13/13/2013';
console.log(date.match(/[0-9]/g).length)
Daniel Gabzdyl
- 135
- 6