Re: pattern match help
| From: | Stuart J. Browne | Date: | Thu, 29 Mar 2001 01:44:57 +0000 |
| Subject: | Re: pattern match help | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-45987@lists.php.net to get a copy of this message | ||
> $str = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";
>
> I need to fetch the 5th charcter after ".....compatible; M" in $str (ie
> '5').
>
> - The following gets me the fifth character along (ie 'l')
> $variable = substr ($str, 5, 1);
>
> How do i tell the substr to start counting from ".....compatible; M(start
> here)"
use a regular expression:
ereg("compatible; [A-Z]+ ([0-9]).*", $str, $variable);
or some such..