help with regular expression
| From: | Barbara Picci | Date: | Thu, 29 Jul 2004 17:57:11 +0000 |
| Subject: | help with regular expression | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-192227@lists.php.net to get a copy of this message | ||
Hi all,
I'm trying from much days to solve a problem with a regular expression...
I'm going to be crazy!
I've a script that must strip a string when it find the first word containing at least 4 characters; it must print the content of the string before that word, that word, a separator and the rest of the string.
I've tried with ereg whit this script (#@# is the separator):
ereg( '^([^ ]{4,})(.*)$', $testo, $matches);
$contents = "$matches[1]#@#$matches[2]\n";
but it is not the right script because if the strin($testo) is "the thing is" the script doesn't find nothing and doesn't print. For this example the right content of $contents must be:
$contents = "the thing#@#is\n";
instead of nothing.
I've tried with thousand of variant of this script but without success.
have you any ideas of the right regular expression?
Thanks in advance.
Bye
Barbara
--