Dec 16, 2009
Regular expressions are very useful when working with text.
We already had ‘match’ operator which can be used in filter expressions. In Mapnik2 we now also have:
<mapnik-expression>.replace(<regex>,<pattern>)
Here is a small example :
from mapnik import * f = Feature(1) f["name"] = 'Mapnik' expr = Expression("[name].replace('(\\B)|( )','$1 ')") expr.evaluate(f)
The above should result in:
'M a p n i k'