Prev: help with DictionaryLookup[] and a type of regular
Next: Number of ways of permutations to form a certain pattern of
From: Bill Rowe on 10 May 2010 06:38 On 5/9/10 at 7:51 AM, nycstern(a)gmail.com (Michael Stern) wrote: >Is there an elegant way to do dictionary searches that match >specified kinds of character repetition? For example, to search for >six letter words that start with "d" and end with "k", where the >third and fourth letter are the same? >Finding six letter words that start with "d" and end with "k" is >easy -- >DictionaryLookup[{"English", RegularExpression["d....k"]}] >But how do we restrict the answer to words where the third and >fourth letters are the same? In[2]:= Cases[ DictionaryLookup[{"English", RegularExpression[ "d....k"]}], _?(SameQ @@ (Characters[#][[{3, 4}]]) &)] Out[2]= {dybbuk}
From: David Bevan on 11 May 2010 06:27 RegularExpression["d.(.)\\1.k"] does what you want using a regex. David %^> > On 5/9/10 at 7:51 AM, nycstern(a)gmail.com (Michael Stern) wrote: > > >Is there an elegant way to do dictionary searches that match > >specified kinds of character repetition? For example, to search for > >six letter words that start with "d" and end with "k", where the > >third and fourth letter are the same? > > >Finding six letter words that start with "d" and end with "k" is > >easy -- > > >DictionaryLookup[{"English", RegularExpression["d....k"]}] > > >But how do we restrict the answer to words where the third and > >fourth letters are the same?
From: Michael Stern on 12 May 2010 07:35
You are my hero. Michael David Bevan wrote: > RegularExpression["d.(.)\\1.k"] > > does what you want using a regex. > > David %^> > > > >> On 5/9/10 at 7:51 AM, nycstern(a)gmail.com (Michael Stern) wrote: >> >> >>> Is there an elegant way to do dictionary searches that match >>> specified kinds of character repetition? For example, to search for >>> six letter words that start with "d" and end with "k", where the >>> third and fourth letter are the same? >>> >>> Finding six letter words that start with "d" and end with "k" is >>> easy -- >>> >>> DictionaryLookup[{"English", RegularExpression["d....k"]}] >>> >>> But how do we restrict the answer to words where the third and >>> fourth letters are the same? >>> > |