Re: ereg_replace() help
| From: | Teodor Cimpoesu | Date: | Wed, 27 Sep 2000 18:54:32 +0000 |
| Subject: | Re: ereg_replace() help | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-17772@lists.php.net to get a copy of this message | ||
Hi David!
On Wed, 27 Sep 2000, David Newcomb wrote:
> The string will follow the patten of
> something<whitespace(s)>something<whitespace(s)>something<whitespace(s)>labl
> e
> <whitespaces><thingIwant><rest of varible>
> eg:
> $text= "one two label four
> otherstuff";
> or
> $text = "one two label
> four
> otherstuff";
> or
> $text = "one two label<tab>four otherstuff";
>
> and the <thingIwant> in the example is "four"
>
> This is what I have so far:
>
> $name=ereg_replace(".*label[ \n]([A-Za-z0-9]+).*","\\1",$text);
>
If you are sure `four' will always be in the fourth position, and the
separator is only in `<blank>,\t,\n' you can use something like:
$text = preg_split ('/\s+/', $text, 5);
$name = $text [3];
-- teodor