To change several fields at once, you can use the field calculator in batch mode (from processing toolbox). This is especially handy when you have a lot of fields to process, as you can use
Autofill… to copy the same settings for all output fields. Add as many rows as you have new fields to create.
For the expression to use, you can define itself an expression (an expression-generated expression, so to say) with
Calculate by Expression…. The expression is based on the comment by @J. Monticolo and the answer by @csk, but uses the variable
@row_number instead for the index operator to batch create each element of the array in a new field.
Be aware, it's a bit tricky, it took me some time to understand, but once you got the principle, it's easy: in the expression builder of the batch window, you have access to the fields of the layer, but not to the variable
@row_number. You have to use
Calculate by Expression… instead to set an expression (string) that generates the final expression. In the
Calculate by Expression… window, you have access to
@row_number, but the fields are not available.
The trick is: insert in the
Calculate by Expression… the expression as a (concatenated) string with single quotes:
' and be sure to mask the single quotes in the delimiter part by another single quote (resulting it two single quotes, not double quotes!). Use pipes
|| for String concatenation:
'string_to_array ("input", delimiter:=''-'' ) [' || @row_number || ']'
When you close the dialog, this expression will be evaluated, resulting in
string_to_array ("input", delimiter:='-' ) [index]
index as an auto-incrementing number from 0 to the last row number (as many as you added).
The output will be generated as a separate file for each field, unfortunately (did not check if there is another option). But by table join, you can re-join the newly created attributes back to your input layer. Again, this is especially efficient if you have a lot of fields to change as you could also use a batch process for the table join.