Answer the question
In order to leave comments, you need to log in
How to count the number of elements in a string in ruby?
There is a line like this
f = '1232132131, 12321321, 34232423423, 324234234234'
You need to count the number of elements. I know that this option works for a list of words.
How can I convert it into a version with numbers, or maybe there is an easier way? f.split(/[^-a-zA-Z]/).size
Answer the question
In order to leave comments, you need to log in
f = '1232132131, 12321321, 34232423423, 324234234234'
f.split.size ## 4
f.split(', ').size ## 4, вот так корректней
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question