Reply to Re: preg_replace question

Your name:

Reply:


Posted by Rik on 06/07/06 00:03

julianmlp@gmail.com wrote:
> I'm fairly new to regex code, and I'm trying to find a way to replace
> any text after "///" (three slashes) and before a "\n" character.
>
>
> I've tried with:
>
> $filen = preg_replace("///./\n$", "", $filen);
> The pattern would mean:
> "string that has three "/" followed by any characters and which ends
> with \n"
>
>
> $filen = preg_replace("//{2}.\n$", "", $filen);
> The pattern would mean:
> "string that has one "/" followed two "/", then followed by any
> character and which ends with \n"
>
>
> What's wrong with these patterns?

1. The first character (in this case '/') is considered the pattern
delimiter, which never closes here...
2. . should match zero or more characters I presume?
3. $ will match only the end on the string without any modifiers, not every
newline.

Possibilities:
$filen = preg_replace("|/{3}.*?$|m", "", $filen);
$filen = preg_replace("|/{3}.*?\n|", "", $filen);

Grtz,
--
Rik Wasmus

[Back to original 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

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