## Re: [Pyparsing] multiple tokens but no repeats

 Re: [Pyparsing] multiple tokens but no repeats From: W. Martin Borgert - 2007-11-20 17:23:38 ```On Tue, Nov 20, 2007 at 03:24:34PM +0000, Tim Grove wrote: > I'm trying to represent the logic that I wish to match 0 or more tokens, > up to a maximum of 4 tokens, but I don't want any repeats of tokens > already matched within the group of 4. How could I do that? I would try setParseAction(), i.e. match 0 to 4 tokens and check myself for duplication. ```

 [Pyparsing] multiple tokens but no repeats From: Tim Grove - 2007-11-20 15:24:40 ```I'm trying to represent the logic that I wish to match 0 or more tokens, up to a maximum of 4 tokens, but I don't want any repeats of tokens already matched within the group of 4. How could I do that? Thanks. Tim ```
 Re: [Pyparsing] multiple tokens but no repeats From: Ralph Corderoy - 2007-11-20 17:10:24 ```Hi Tim, > I'm trying to represent the logic that I wish to match 0 or more > tokens, up to a maximum of 4 tokens, but I don't want any repeats of > tokens already matched within the group of 4. How could I do that? I'm not sure if you can. Perhaps there's a way to run your own validation code as each attempt to grow the number of matches occurs? Otherwise, since there's only four I'd enumerate the alternatives, e.g. a ab ac ad abc abd acb acd adb adc abcd abdc acbd acdb adbc adcb If I've got that right, there's 16 alternatives starting with `a'. The other three follow a similar pattern making 64 in total. You could factor out the common prefixes to speed up a Regex() a bit if you find that just a dumb list seems slow. Be sure to check whether order determines whether it matches the longest possible, e.g. `abcz' should match `abc' and not `a' or `ab'. Cheers, Ralph. ```
 Re: [Pyparsing] multiple tokens but no repeats From: Paul McGuire - 2007-11-24 16:04:44 ```Since these are supposed to represent the 4 fingers on your hand, can you really have the out-of-order permutations? Or are you really just looking at the 16 values of corresponding to the binary values 0000 to 1111? What is the significance of a symbol meaning "pinky finger on opposite side of index finger"? -- Paul -----Original Message----- From: Ralph Corderoy [mailto:ralph@...] Sent: Tuesday, November 20, 2007 11:10 AM To: Tim Grove Cc: pyparsing-users@...; Paul McGuire Subject: Re: [Pyparsing] multiple tokens but no repeats Hi Tim, > I'm trying to represent the logic that I wish to match 0 or more > tokens, up to a maximum of 4 tokens, but I don't want any repeats of > tokens already matched within the group of 4. How could I do that? I'm not sure if you can. Perhaps there's a way to run your own validation code as each attempt to grow the number of matches occurs? Otherwise, since there's only four I'd enumerate the alternatives, e.g. a ab ac ad abc abd acb acd adb adc abcd abdc acbd acdb adbc adcb If I've got that right, there's 16 alternatives starting with `a'. The other three follow a similar pattern making 64 in total. You could factor out the common prefixes to speed up a Regex() a bit if you find that just a dumb list seems slow. Be sure to check whether order determines whether it matches the longest possible, e.g. `abcz' should match `abc' and not `a' or `ab'. Cheers, Ralph. ```
 Re: [Pyparsing] multiple tokens but no repeats From: W. Martin Borgert - 2007-11-20 17:23:38 ```On Tue, Nov 20, 2007 at 03:24:34PM +0000, Tim Grove wrote: > I'm trying to represent the logic that I wish to match 0 or more tokens, > up to a maximum of 4 tokens, but I don't want any repeats of tokens > already matched within the group of 4. How could I do that? I would try setParseAction(), i.e. match 0 to 4 tokens and check myself for duplication. ```