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

**URL:** <https://discourse.julialang.org/t/from-string-vec-only-rows-starting-like-bib-what-wrong/16308>\
**Category:** General Usage\
**Created:** [October 14, 2018, 2:49pm UTC](https://discourse.julialang.org/t/from-string-vec-only-rows-starting-like-bib-what-wrong/16308 "2018-10-14T14:49:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![programista](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/programista/32/5372_2.png) [@programista](https://discourse.julialang.org/u/programista)\
**Post date:** [October 14, 2018, 2:49pm UTC](https://discourse.julialang.org/t/from-string-vec-only-rows-starting-like-bib-what-wrong/16308/1 "2018-10-14T14:49:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [October 14, 2018, 3:10pm UTC](https://discourse.julialang.org/t/from-string-vec-only-rows-starting-like-bib-what-wrong/16308/2 "2018-10-14T15:10:30Z")

</div>

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

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

```

---

<div class="post-metadata">

**Author:** ![bkamins](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bkamins/32/208538_2.png) [@bkamins](https://discourse.julialang.org/u/bkamins)\
**Post date:** [October 14, 2018, 3:52pm UTC](https://discourse.julialang.org/t/from-string-vec-only-rows-starting-like-bib-what-wrong/16308/3 "2018-10-14T15:52:26Z")

</div>

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.
