Could you please help with preg_replace
regex for trimming letter/words if appears after 2 or more white spaces? i.e.:
lorem ipsum x
to become
lorem ipsum
also would be great to left trim if word/letter followed by 2 white spaces i.e.
x lorem ipsum
The following should match 2 or more whitespaces, followed by any number of consecutive "word" characters
$rx = "/\s{2,}\w*/";
Here's the regex that will match the criteria you described (note the leading spaces may be hard to see):
\w+?\b
Demo: http://gskinner.com/RegExr/?2ucpq
Edit: looks like to make this actually work in PHP, you need leading and trailing slashes:
preg_replace('/ \w+?\b/','','testing pro x');