It's possible to test item tag in clear command but it's impossible to test in selector with nbt.
Example:
/execute as @a[nbt={SelectedItem:{id:"#minecraft:planks"}}] run say @s have Planks
No match in this case.
Linked issues
relates to 1
Comments 3
I don't want to test NBT tag but Item tag name, like block tag or function tag. it's possible to write item or block tag name in CanDestroy/CanPlaceOn, why not for NBT testing?
NBT has to match exactly, and the id is not “#minecraft:planks”.