String search()

Methods search() and contains() for strings existing??

Yes, see e.g. findfirst and occursin.

1 Like

For example: contains(“ff”, “wawaffeses”)
REPL write:
Error:UndefVarError:contains not defined
and
search(“ff”, “wawaffeses”)
REPL write:
Error:UndefVarError:search not defined

julia> occursin("ff", "waffles")
true

(Although I really hate that the needle is in first position here.)

This is very nice)), but contains() and search() exist?

From Julia v1.5 news:
New function contains(haystack, needle) and its one argument partially applied form have been added, it acts like occursin(needle, haystack) #35031

Why my Julia 1.4.1 writes error? It is normal?

Yes, as Greg says above, the contains function was added in Julia 1.5 (not released yet), so is not available in 1.4.1. As others have pointed out, you can use occursin, which does the same thing, just with a different ordering of input arguments.

1 Like

Thanks!!