You are here: Re: [PHP] Re: Substr by words « PHP « IT news, forums, messages
Re: [PHP] Re: Substr by words

Posted by Marcus Bointon on 10/31/05 01:19

On 30 Oct 2005, at 15:35, Gustavo Narea wrote:

> I think that trim($matches[0]) will return the whole string with no
> change.

No, it will return the entire matching pattern, not just the sub-
matches. I added the trim to remove any leading space, and there will
nearly always be a trailing space because of the part of my pattern
that defines a word will include it. It was simpler to use trim than
to make the pattern skip it. Did you actually try it?

> On the other hand, I think we have to place a caret after the first
> slash.

Only if you insist that your string must start with a word - putting
a ^ at the start would make it omit the first word if there was a
space in front if it.

> Instead of preg_match(), I had to type preg_replace():

err. I think you missed the point here. You don't need all that messy
substr stuff at all. The preg_match already did it.

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация