I have a string, “Hello there I have a question”
I want to delete all one charactered words from this string. It must look like “Hello there have question”
I’ve done this:
$yt_tags = preg_replace('/[\w]{1}/','',$yt_tags);
But it deletes everything in the string.
Thanks for your help.
Use a word-boundary (
\b):I added in the
\s*to ‘trim’ unneeded extra whitespace (word<space>a<space>wordwould otherwise become:word<space><space>wordinstead ofword<space>word).