Replace file content after checking value

Our system is receiving one feed from the third party.

One of the field in the flat file is ID which id from position 19 to 27. In some cases this ID is coming as 9 zeros (000000000) or 1 right padded zero. ( 0)

For these specific records I want to replace fthis field with blank spaces. ( 9 blank spaces) . The simple replace is simple but I am not able to figure out that how will I compare the field first and then replace.

Check the field and if it is as 9 zeros (000000000) or 1 right padded zero.
( 0) then replace with 9 blanks.

Kindly note that for most of the cases the field is having the correct value , only few hundreds records have this problem in the file.

Have you tried using sed?

sed s/<pattern to search for>/<what to replace with>/g <filename>

I can use sed for replacing , but the thing is that I have to check the values first , and only when condition is satisfied I need to replace it with my values.

Could you please suggest something to handle the conditional replacement.

It will be better, if you can provide sample date to us.