From String vec only rows starting like "bib" . What wrong?

I need only rows of bazab wnen strings are starting from “bib” . What wrong ?

julia> (x->x(1:3)==“bib”,bazab)
(#117, SubString{String}[“babilońskość”, “bab
tterka”, “bacewiczówna”, “bachanalijka”, “bac
kawicowo”, “błyskawiczny”, “błyskotliwie”, “b
itnonogi”])

julia> (x->x[1:3]==“bib”,bazab)
(#119, SubString{String}[“babilońskość”, “bab
tterka”, “bacewiczówna”, “bachanalijka”, “bac
kawicowo”, “błyskawiczny”, “błyskotliwie”, “b
itnonogi”])

Paul

You need to put a bit more love into your question for anyone to be able to help you.
In the first line, you create a tuple with a function and bazab (which you have not defined in your question). You also use matlab style array indexing in the first line.

Try

filter(bazab) do str
    str[1:3] == "bib"
end
3 Likes

One small comment. You should not index into a string like str[1:3] as it will fail e.g. when str="Łęg". The correct way to do it in this case is first(str, 3) as it correctly handles characters with varying length of encoding.

Additionally in this special case there is startswith function that can be used directly.

2 Likes