Re: [julia-users] How to: grep an Array of strings

2015-12-03 Thread Seth
Makes sense. Thanks! On Thursday, December 3, 2015 at 1:06:16 PM UTC-8, Stefan Karpinski wrote: > > There's an obvious predicate implied by a Regex: does it match a string? > What's the obvious predicate for a string? Checking whether it is contained > in another string is one option but that's

Re: [julia-users] How to: grep an Array of strings

2015-12-03 Thread Stefan Karpinski
There's an obvious predicate implied by a Regex: does it match a string? What's the obvious predicate for a string? Checking whether it is contained in another string is one option but that's pretty arbitrary. You could just as well check for containment the other way. Or prefix, or suffix, etc. O

Re: [julia-users] How to: grep an Array of strings

2015-12-03 Thread Seth
That's really elegant. Is there a reason filter() is defined for regex strings but not ASCIIStrings? On Thursday, December 3, 2015 at 12:55:50 PM UTC-8, Stefan Karpinski wrote: > > You can just pass a Regex object to filter: > > filter(r"a.*b.*c"i, map(chomp,open(readlines,"/usr/share/dict/words"

Re: [julia-users] How to: grep an Array of strings

2015-12-03 Thread Stefan Karpinski
You can just pass a Regex object to filter: filter(r"a.*b.*c"i, map(chomp,open(readlines,"/usr/share/dict/words"))) This gives all dictionary words containing "a", "b" and "c" in order but not contiguous. On Thu, Dec 3, 2015 at 3:29 PM, David P. Sanders wrote: > > > El jueves, 3 de diciembre d

Re: [julia-users] How to: grep an Array of strings

2015-12-03 Thread David P. Sanders
El jueves, 3 de diciembre de 2015, 13:54:01 (UTC-6), Erik Schnetter escribió: > > You are looking for `filter`: > > filter(line->match(r"parameter", line), rLines) > Apparently this needs to be filter(line->ismatch(r"3", line) != nothing, rLines) (replace "match" with "ismatch" to get a Boo

Re: [julia-users] How to: grep an Array of strings

2015-12-03 Thread Erik Schnetter
You are looking for `filter`: filter(line->match(r"parameter", line), rLines) -erik On Thu, Dec 3, 2015 at 2:52 PM, 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=

[julia-users] How to: grep an Array of strings

2015-12-03 Thread Jason McConochie
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"