Another slight modification, which takes care to disallow any other subsequent attributes apart from background: Markup('background', 'directive', '/\\(:background\\s+((#\\w+,\\s*)*#\\w+\\s*{\\s*background:[^{};]*?[;]*\\s*})\\s*:\\)/e', "PZZ(\$GLOBALS['HTMLStylesFmt'][] = PSS(' $1 '))"); ~Hans