Question: I'm working on a regular expression where I need to verify a input text that contains 4 distinct words separated by a comma. 

> 
> input text words: - one, two, three, four. Each of these words should not be repeated more than once. 
>  so, it can be: two, three, four, one or three, four, two, one and not one, one, one, one
> 
> 
> 

Here is what I wrote and found a partial solution by doing separate searches

```
^\b(one|two|three|four)\b?,\b(one|two|three|four)\b?,\b(one|two|three|four)\b?,\b(one|two|three|four)\b

```

But the problem with solution is words are getting repeated, and the test for "one, one, one, one" fails.

Can you please let me know how to avoid the duplicates and where am I doing a mistake?

Answer: 
```
boolean valid( String input ) {
  input.tokenize( ',' ).with { list ->
    list.unique( false ) == list &&
      list.every { it in ['one','two','three','four'] }
  }
}

```

should do it without regular expressions
You can use negative lookaheads in this way (see at [Regexr](http://regexr.com?32k60)):

```rb
\b(one|two|three|four)\b,             # match one of the allowed words
\b(?!\1)(one|two|three|four)\b,       # match one of them but not first matched one
\b(?!\1|\2)(one|two|three|four)\b,    # match one of them but not first and second matched ones
\b(?!\1|\2|\3)(one|two|three|four)\b  # match one of them but not first, second and third matched ones

```