This is a discussion on string processing question within the PHP Language forums, part of the PHP Programming Forums category; Given a string: 'aaa bbbb cccc' or a string: 'aaaa bbb cc' I want to find and delete any word ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
"leegold" <leegold@nospam.com> wrote in message
news:D8OdnStQkasrgInfRVn-jg@rcn.net... > Given a string: 'aaa bbbb cccc' > or a string: 'aaaa bbb cc' > > I want to find and delete any word within a string with 3 or less chars. > so I would get: > 'bbbb cccc' > 'aaaa' > as results after processing. > > How would I do this in PHP? > > Thanks preg_replace('/\b\S{1,3}\b\s*/', '', $text) should do it. |