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