I have 45 maps produced with Atlas. I would like to save them with their names. However, there are character in these names that windows doesn't accept in file name. So, I'm tring to do a expression which replace this kind of characters to "_". I am doing it in output file name expression (panel in Genarate an Atlas).

So, here is my code. It isn't work what I want.

a = lower("field_name")
b = '-/"()' #characters to replace -, ", ( and ).
for char in a:  
    a = a.replace(char, "_")

You can use a regular expression:

regexp_replace(  "your_attribute" , '[^A-Za-z0-9]+', '_')

This will replace all non-alphanumeric characters with an underscore.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.