string processing question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • leegold

    string processing question

    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
  • Chung Leong

    #2
    Re: string processing question

    "leegold" <leegold@nospam .com> wrote in message
    news:D8OdnStQka srgInfRVn-jg@rcn.net...[color=blue]
    > 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[/color]

    preg_replace('/\b\S{1,3}\b\s*/', '', $text) should do it.


    Comment

    Working...