|
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
Navigation:
[Reply to this message]
|