Find occurrences of a character in a string using Ruby

Опубликовано: 13 Март 2025
на канале: FREAKIN’ FAST Tutorials
1,021
18

In this video, I show two methods I've used when programming in cases where I need to find the occurrences of a character in a string. In this example, I'm using the Ruby programming language.

The first method outputs the number of times a character occurs, which is done using Ruby's count method. The second method, scan, differs in that instead of returning a count, it returns the characters themselves.

I use both count and scan when cleaning data for use in code or for data mining.