I need to replace in string foo bar foo bar bar foo all foo to bar and all bar to foo. So the result should
foo bar foo bar bar foo
foo
bar