Re: preg_match() occurence position
| From: | lallous | Date: | Thu, 25 Jul 2002 13:05:36 +0000 |
| Subject: | Re: preg_match() occurence position | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-109481@lists.php.net to get a copy of this message | ||
Yes, I'm aware of the strpos() or any other non-regexp string functions...
but it is either I use regexp to match a certain pattern or I'll have to
write a char-by-char parser to emulate regexp searching and yet get the
position of the occurence!
Thank you all anyway.
//Elias
"Alexander Kuznetsov" <sanych@cstrade.koenig.ru> wrote in message
news:7586019379.20020725144631@cstrade.koenig.ru...
> Hello lallous,
>
> Thursday, July 25, 2002, 3:40:32 PM, you wrote:
>
> l> Hello,
>
> l> Can I get the starting position of my string occurence when using any
> l> regexps searching functions in PHP ?
>
> l> for example:
> l> $mem='this is a test';
> l> preg_match('/test/', ...) should return me somehow: 10
>
>
> l> Thanks
>
>
> why regexps?
> what about simple string fuctions in PHP?
>
> for your example they will be more usefull:
>
> strrpos - http://www.php.net/manual/en/function.strrpos.php
>
> sample:
>
> $text = "string";
> echo strrpos($text, "r"); // must show 2 as result
>
>
>
> --
> Best regards,
> Alexander Kuznetsov
>
>