Re: Re: Substr by words

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 31 Oct 2005, at 03:29, Gustavo Narea wrote:

I think It is OK what I said about the caret, but what we need to change is the position of \W*:
   Your suggestion: /(\b\w+\b\W*){1,$MaxWords}/
   My suggestion: /^(\W*\b\w+\b){1,$MaxWords}/

We need the *first* ($MaxWords)th words.

I makes no difference - they will both work. Mine doesn't care where the first word starts because it doesn't use ^, and yours doesn't care where the first word starts because it's got ^ followed by \W*. Your overall match will end up with leading spaces, mine will end up with trailing spaces - the subsequent trim fixes them both. I like mine because it has 1 less char ;^)

Ultimately, if it works for you, great!

Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
marcus@xxxxxxxxxxxxxxxxxx | http://www.synchromedia.co.uk

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux