Andreas Dölling: Probleme mit RegEx Folge 13: Backreference

Beitrag lesen

Hallo,

hm, ich kann Dir da im Moment leider nicht weiterhelfen.
Allerdings scheint bei mir Dein Code zu funktionieren:
<?php
// Test
function getColorForPDF($color, $type) {
 return 'XXX'.$color.'+'.$type.'XXX';
}

$theText = 'Dies ist ein <font face="Arial" color="#aa0000">toller</font> Test!';

$theText = eregi_replace('(<font [^<]*color=["|']?([^ "']*)["|']?^></font>)','<fillcolor={ cmyk ' . getColorForPDF('\2', 'c') . ' ' . getColorForPDF('\2', 'm') . ' ' . getColorForPDF('\2', 'y') . ' ' . getColorForPDF('\2', 'k') . ' }\3<fillcolor={ ' . $sDefaultTextColor . ' }>', $theText);

echo htmlentities($theText);
?>

Gibt folgendes aus:
Dies ist ein <fillcolor={ cmyk XXX#aa0000+cXXX XXX#aa0000+mXXX XXX#aa0000+yXXX XXX#aa0000+kXXX }>toller<fillcolor={ }> Test!

Was ja korrekt ist.

Ciao,
Andreas

--
"Das Corporate Design für das Internet sieht eine Reihe von Grafikelementen vor, die die Optik der Webseite visuell und funktionell beeinflussen." - (Zitat aus dem "Styleguide Corporate Design"  eines großen Konzerns...)