<?php$q = "ball ball foo bar bar baz";$q = preg_replace("/\b(\w+)\s+\\1\b/i", "$1", $q);echo $q;?>
Standard input is empty
ball foo bar baz
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!