I don't know if this is the best way but:

$str = "This is or was a test for short words";

while (ereg(" [a-z]{1,3} ", $str)) {
 $str = eregi_replace(" [a-z]{1,3} ", " ", $str);
}
print $str;


this replaces all occurences of a space followed by 1,2 or 3 alphabetic
characters followed by a space... the reason why it's performed in a while
loop is because of two or more short words following each other and thus
sharing a space...


Greets,

Edward



----- Original Message -----
From: "Michael Kimsal" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, February 07, 2002 11:58 PM
Subject: [PHP] Regex function needed


> Looking for a regex (preg or ereg) to remove
> all 1, 2 and 3 character words.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to