If you don't like regexes,

julia> a = ["apple","bear","ape","collar"]
4-element Array{ASCIIString,1}:
 "apple"
 "bear"
 "ape"
 "collar"


julia> filter(x->contains(x,"ap"),a)
2-element Array{ASCIIString,1}:
 "apple"
 "ape"


julia> filter(x->contains(x,"ar"),a)
2-element Array{ASCIIString,1}:
 "bear"
 "collar"


On Thursday, December 3, 2015 at 11:52:34 AM UTC-8, Jason McConochie wrote:
>
> Is there grep for an Array of AbstractStrings?  See code below
>
>
> # A. Read a file into memory (nLines pre-determined)
>
> fID=open(fName)
>
> iLine=0;
>
> rLines=Array(ASCIIString,nLines);
>
> while !eof(fID)
>
>   iLine+=1
>
>   rLines[iLine]=readline(fID)
>
> end
>
>
> # B. Find all strings in rLines with "parameter"
>
> ???? Is something like this possible?
>
> indices=grep(rLines,r"parameter")
>
>
>
>

Reply via email to