Re: RegEx: find words in random order

"Tim Chase [email protected] [sed-users]" <[email protected]>
Newsgroups gmane.editors.sed.user
Message-ID <[email protected]>
On 2015-04-08 14:49, [email protected] [sed-users] wrote:
> A RegEx should match, when 2 words are found in one text-line in
> random order.

Just FYI, "random" has a technical meaning to most geeks, so I'd
suggest the word "arbitrary".

> For a simplified example, it should return true, wenn the line
> contains "color" and one of the words "blue" and "red": 
> "bluecolor", "blue-color" or "red color", "color red"...

You don't mention what you want to do with the matches.  You could do
something like

  sed -n '/color/{/red\|blue/p}'

which would first filter for lines containing "color" and then, if
"red\|blue" is found on the same line, print it.

-tim
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.