Re: [PHP] preg_match() occurence position

2002-07-25 Thread Jason Wong
On Thursday 25 July 2002 20:40, lallous wrote: Hello, Can I get the starting position of my string occurence when using any regexps searching functions in PHP ? for example: $mem='this is a test'; preg_match('/test/', ...) should return me somehow: 10 No. If search string does not

Re: [PHP] preg_match() occurence position

2002-07-25 Thread Alexander Kuznetsov
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

RE: [PHP] preg_match() occurence position

2002-07-25 Thread John Holmes
Can I get the starting position of my string occurence when using any regexps searching functions in PHP ? for example: $mem='this is a test'; preg_match('/test/', ...) should return me somehow: 10 Does it have to be a regular expression you are searching for? If not, you can use

Re: [PHP] preg_match() occurence position

2002-07-25 Thread lallous
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

Re: [PHP] preg_match() occurence position

2002-07-25 Thread Michael Sims
On Thu, 25 Jul 2002 15:05:36 +0200, you wrote: l for example: l $mem='this is a test'; l preg_match('/test/', ...) should return me somehow: 10 How about this: $mem='this is a test'; if(preg_match(/(.*)test/,$mem,$matches)) { echo strlen($matches[1]); } Of course, if test occurs more

Re: [PHP] preg_match() occurence position

2002-07-25 Thread Tim Fountain
On Thursday, July 25, 2002, Michael Sims wrote: On Thu, 25 Jul 2002 15:05:36 +0200, you wrote: for example: $mem='this is a test'; preg_match('/test/', ...) should return me somehow: 10 How about this: $mem='this is a test'; if(preg_match(/(.*)test/,$mem,$matches)) { echo

Re: [PHP] preg_match() occurence position

2002-07-25 Thread Justin French
on 25/07/02 11:05 PM, lallous ([EMAIL PROTECTED]) wrote: 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

Re: [PHP] preg_match() occurence position

2002-07-25 Thread lallous
Yes, I've done it before too...but I saw some other libraries(in other programming langs) that has such features... Justin French [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... on 25/07/02 11:05 PM, lallous ([EMAIL PROTECTED]) wrote: Yes, I'm aware of the

Re: [PHP] preg_match() occurence position

2002-07-25 Thread Tech Support
How about this: $text = this is test; preg_match can return the first match in an optional array I'll call $matches http://www.php.net/manual/en/function.preg-match.php preg_match('/test/', $text, $matches); strpos returns the numeric position of the first occurrence

Re: [PHP] preg_match() occurence position

2002-07-25 Thread Miguel Cruz
On Thu, 25 Jul 2002, lallous wrote: 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! Once