I have a question regarding pattern searching with grep.
I have read tutorials all over the place and pretty much understand how to search for patterns and recurring patterns. I, however, need to search for words which have non-repeating occurances.
My task is to parse a 'permissions' string, ie "ug=rx,o=rw" or "ugo=rwx"
Take the string 'ugo' or 'oug', I basicaly need "grep [ugo][ugo][ugo] but they cannot repeat.
I guess I wasnt't too clear. Lets take an example:
The string in question can be an anagram of 'ugo', ie uog, gou, etc.
I need a regular expression to search for a string like this, where there are only 3 allowed characters, can be in any order, and are not allowed to repeat.
There is no provision to inline the requirement that there be at least one of ugo and one of rwx for the expression to match; with Perl, you can do lookaheads which accomplish this.
(?=[ugo])u?g?o?(=(?=[rwx]r?w?x?))?
Multiple comma-separated repetitions of this pattern left as an exercise.
Posted while you added your clarification. The above doesn't exactly match your refined requirements. I don't think you can get arbitrary order without repetition without enumerating the possible permutations.