Search code examples
julia

Getting count of occurrences for X in string


Im looking for a function like Pythons

"foobar, bar, foo".count("foo")

Could not find any functions that seemed able to do this, in a obvious way. Looking for a single function or something that is not completely overkill.


Solution

  • This is now just count:

    julia> count("foo", "foobar, bar, foo")
    2