Thursday, 15 March 2018

replace - Replacing '+' with ', ' for labels in QGIS?


I want to replace a '+' with ', ' to label an attribute looking like "ZT10+ZT20+ZT30" to get "ZT10, ZT20, ZT30" using



regexp_replace("zone_nr", '+', ', ')

but I get an Eval Error: Invalid regular expression '+': quantifier does not follow a repeatable item.



Answer



A + is a special symbol to the QGis regular expression engine (it means 1 or more of the preceding character), so you need to escape it by putting a \ in front of it. So you need:


regexp_replace("zone_nr", '\\+', ', ')

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...