/((fred|wilma) (flintstone)) \2/ # could be fred flintstone fred /((fred|wilma) (flintstone)) \1/ # could be fred flintstone fred flintstone /((fred|wilma) (flintstone)) \3/ # could be fred flintstone flintstone