Such functionality isn't in-built into the fill command. I've tried it before, and my solution was to have an armor stand scan over the area and replace the blocks you want.
Note this method is the most laggy, as you will have an armor stand at every block on the XZ plane at one point. It can be simplified, but it will take longer to run. Use at own risk, and do not use for exceedingly large areas!
You will need 3 dummy scoreboard objectives, named fillReplaceX, fillReplaceY and fillReplaceZ.
Start by resetting all the objectives:
/scoreboard players reset fillReplaceX
/scoreboard players reset fillReplaceY
/scoreboard players reset fillReplaceZ
Then summon a unique armor stand:
/execute positioned [corner of area, lowest coordinates xyz] run summon minecraft:armor_stand ~ ~ ~ {Tags=["fillReplaceAlongX"]}
Then power this:
[repeat] /execute as @e[type=minecraft:armor_stand,tag=fillReplaceAlongX] at @s if score @s fillReplaceX matches ..[x size of area] run summon minecraft:armor_stand ~ ~ ~ {Tags=["fillReplaceAlongZ"]}
[conditional] /execute as @e[type=minecraft:armor_stand,tag=fillReplaceAlongX] at @s run tp @s ~1 ~ ~
[conditional] /execute as @e[type=minecraft:armor_stand,tag=fillReplaceAlongX] run scoreboard players add @s fillReplaceX 1
Then:
/execute as @e[type=minecraft:armor_stand,tag=fillReplaceAlongX] run scoreboard players reset @s fillReplaceX
/kill @e[type=minecraft:armor_stand,tag=fillReplaceAlongX]
Once that is completed power this:
[repeat] /execute as @e[type=minecraft:armor_stand,tag=fillReplaceAlongZ] at @s if score @s fillReplaceZ matches ..[z size of area] run summon minecraft:armor_stand ~ ~ ~ {Tags=["fillReplaceFinal"]}
[conditional] /execute as @e[type=minecraft:armor_stand,tag=fillReplaceAlongZ] at @s run tp @s ~ ~ ~1
[conditional] /execute as @e[type=minecraft:armor_stand,tag=fillReplaceAlongZ] run scoreboard players add @s fillReplaceZ 1
Then:
/execute as @e[type=minecraft:armor_stand,tag=fillReplaceAlongZ] run scoreboard players reset @s fillReplaceZ
/kill @e[type=minecraft:armor_stand,tag=fillReplaceAlongZ]
Once that is completed power this:
[repeat] /execute as @e[type=minecraft:armor_stand,tag=fillReplaceFinal] at @s if score @s fillReplaceY matches ..[y size of area] run [COMMAND TO RUN OVER AREA]
[conditional] /execute as @e[type=minecraft:armor_stand,tag=fillReplaceFinal] at @s run tp @s ~ ~1 ~
[conditional] /execute as @e[type=minecraft:armor_stand,tag=fillReplaceFinal] run scoreboard players add @s fillReplaceY 1
And finally, kill the armor stands.
/execute as @e[type=minecraft:armor_stand,tag=fillReplaceFinal] run scoreboard players reset @s fillReplaceY
/kill @e[type=minecraft:armor_stand,tag=fillReplaceFinal]
Replace [COMMAND TO RUN OVER AREA] with what will be done for every block in the area. If you wanted to replace all stone in the area with air, then enter:
execute if block ~ ~ ~ minecraft:stone run setblock ~ ~ ~ minecraft:air
I may have gotten some syntax wrong, as this is from memory. LMK and I will fix.
Edit: If you want to run multiple commands over the area, just add another command block as a conditional chain, before the TP command:
/execute as @e[type=minecraft:armor_stand,tag=fillReplaceFinal] at @s run [COMMAND TO RUN OVER AREA]
0makes me assume MCBE, but it could also be MCJava 1.12.2. – Fabian Röling Feb 22 '20 at 14:55