I would like to delete all fields with the string "RAWI". For instance the field "RAWI_WA" and the field "RAWI_BO" should be deleted but not the field "NSG_RAW"
You can use the following code in the Python console which, for your selected layer, deletes all fields which contains
RAWI in the field name:
layer = qgis.utils.iface.activeLayer() # Get field names of layer field_names = [field.name() for field in layer.fields()] # Use `with edit()` method to edit and commit changes in one go with edit(layer): # Assign count in reverse order for each field which will be used as index for i, j in reversed(list(enumerate(field_names))): if "RAWI" in j: layer.deleteAttribute(i)