Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Count the number of integers in a string

how can I count the number of integers in a string using jQuery or javascript?

For example g66ghy7 = 3

like image 396
David Avatar asked Oct 05 '11 07:10

David


People also ask

How do you count the number of int in a string in Python?

First we find all the digits in string with the help of re. findall() which give list of matched pattern with the help of len we calculate the length of list and similarly we find the total letters in string with the help of re. findall() method and calculate the length of list using len.

How do you count the number of numbers in a string in Java?

isDigit(s. charAt(i)) will count the number of digits in the given string. 'Character. isDigit' will count the number of each digit in the string.


1 Answers

alert("g66ghy7".replace(/[^0-9]/g,"").length); 

Look here.

like image 107
Petar Ivanov Avatar answered Sep 29 '22 04:09

Petar Ivanov