Re: Re: Substr by words
| From: | Marcus Bointon | Date: | Sun, 30 Oct 2005 23:19:49 +0000 |
| Subject: | Re: Re: Substr by words | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-224849@lists.php.net to get a copy of this message | ||
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