I am trying to search through a string to find the number of occurences of a substring. I am doing this for all the strings in an array of strings. I only have figured out the while loops so far. How can I traverse through an array of strings using a for loop?

You don't need to use a loop if you take advantage of the API. If you take the length of the array returned "scanning" for your substring with String#scan , you will have number of occurrences of that substring.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.