$line = 'this is a regular expression';
$line =~  s/^(\w+)\b(.*)\b(\w*)$/[\3] [\2] [\1]/;

print $line;