Is there a way I can count the number of integers in an array? I have an array whose members come from a-z and 0-9. I want to count the number of integers in said array. I tried:
myarray.count(/\d/)
...but the count method doesn't regex.
a = 'abcdefghijklmnopqrstuvwxyz'.split('')
a << [0,1,2,3,4,5,6,7,8,9]
t = a.sample(10)
p t.count(/\d/) # show me how many integers in here
count(obj)uses==to count the number of elements equal to obj. So unless you're counting an array of regular expressions your code won't work. Moreover if it did work it still wouldn't count the integers because regex is used with strings.