Rules-based string formatter.