I would suggest to simply complete the task in two step.
First, Generate the comma seperated list of tables that start with B and are required to drop
select name+', '
where type = 'U'
and name like 'M%'
Then analyze the names and put the comma seperated result in drop statement.
It would simplyfy the task and you would have option to analyze the names of tables that you are going to drop.