1

Given : two words; "new", "intermediate"

I need to find any string that contains the two given words,

Good Strings:

  • "This is the new and intermediate way of doing this".
  • "This is the intermediate and new way of doing this".

Bad Strings:

  • "This is new and limited".
  • "This is intermediate or limited".

The rules are:

  • both "new" and "intermediate" must be in the strings.
  • case should be ignored
  • the order of the words does not matter
  • the position of the match is not important.

TIA

This seems to work, but is there a better way? ^(.?\bnew\b.?\intermediate\b.?)|(.?\bintermediate\b.?\bnew\b.?)$

Edit: My question maybe the same, except I'm in C# not Ruby (does it make a difference?)

Edit: Checking the suggested answer, shows it works for C# Regex. Sorry for the duplicate question.

Alan Wayne
  • 5,122
  • 10
  • 52
  • 95

0 Answers0