Damn, jeg er helt blank. Jeg har absolut ingen erfaring med RE!
Alle funktioner til eksterne links, givet ved [el]target[/el] og [el=target]title[/el], fungerer nu. Så kommer det svære: Interne links!
Jeg har rettet lidt:
class Formatting
{
public static $Patterns = array
(
"h1" => "#\[h1\](.*?)\[/h1\]#",
"h2" => "#\[h2\](.*?)\[/h2\]#",
"h3" => "#\[h3\](.*?)\[/h3\]#",
"b" => "#\[b\](.*?)\[/b\]#",
"i" => "#\[i\](.*?)\[/i\]#",
"u" => "#\[u\](.*?)\[/u\]#",
"il1" => "#\[il\](.*?)\[/il\]#e",
"il2" => "#\[il=*.?\](.*?)\[/il\]#e",
"el1" => "#\[el\]([0-9a-zA-Z_-]+)\.([a-z]{2,4})\[/el\]#",
"el2" => "#\[el\]([0-9a-zA-Z_-]+)\.([a-z]{2,4})/(.+)\[/el\]#",
"el3" => "#\[el=([0-9a-zA-Z_-]+)\.([a-z]{2,4})\](.+)\[/el\]#",
"el4" => "#\[el=([0-9a-zA-Z_-]+)\.([a-z]{2,4})/(.+)\](.+)\[/el\]#"
);
public static $Replacements = array
(
"h1" => "<h1>$1</h1>",
"h2" => "<h2>$1</h2>",
"h3" => "<h3>$1</h3>",
"b" => "<b>$1</b>",
"i" => "<i>$1</i>",
"u" => "<u>$1</u>",
"il1" => "'<a title=\"'.Page::GetPage(\\0, true)->Title.'\" href=\"?location=\\0\">'.Page::LastPage(\\0)->Title.'</a>'",
"il2" => "'<a title=\"'.Page::GetPage(\\0)->Title.'\" href=\"?location=\\0\">\\1</a>'",
"el1" => "<a title=\"www.$1.$2\" href=\"http://www.$1.$2/\" target=\"_blank\">$1.$2</a>",
"el2" => "<a title=\"www.$1.$2/$3\" href=\"http://www.$1.$2/$3\" target=\"_blank\">$1.$2/$3</a>",
"el3" => "<a title=\"www.$1.$2\" href=\"http://www.$1.$2/\" target=\"_blank\">$3</a>",
"el4" => "<a title=\"www.$1.$2/$3\" href=\"http://www.$1.$2/$3\" target=\"_blank\">$4</a>"
);
public static function Convert($string)
{
return preg_replace(self::$Patterns, self::$Replacements, $string);
}
}
Indlæg senest redigeret d. 23.04.2011 09:02 af Bruger #14505