Selective collapsing -or not

Hello there, many thanks for the software and for the efforts of all the people in this forum.
My question is about collapsing under certain circumstances.
Let me explain with the following example:
[1] I built a fair number of questions and an associated set of answers (for an online lesson).
[2] Each question (a note/file), at the end is having the link to its answer, in the form [[…]]], so it is super handy to show or not show the question while explaining, while solving or while revisiting the solution. If I want for the answer to automatically pop-up I just include the exclamation point as in: ![[…]]].
[3] Now consider the scenario I built an exam by selecting a number of questions, and there is no way to exclude the answers to show in the exported pdf, other than having no exclamation mark in front of all links (otherwise there will be proudly shown under each question of course).
[4] That means I have to manually care about deleting the ! in front all the questions associated with the exam.
[5] Then, as I deliver the answers, I must export the same exam as pdf, but now I have to re-introduce the ! in front off each answer’s link in order for them to populate my pdf nicelly.
Is there a way to do the whole procedure more like automated? Obsidian shows a great potential in education and at the moment I tend to stretch it towards this direction -great tool.

I don’t believe there is an automated way to do this in Obsidian. You can open the file in an application like Visual Studio code and use the “find and replace” feature and replace all ! with nothing to quickly delete exclamation points.

By using yaml? Templates?
Thanks for your response.

I just realized that you can actually do this in Obsidian. Just hit command/control + f and type !. Then, press “replace” to remove the highlighted instance of !. If you don’t want to remove a certain exclamation point, just press next to move onto the next instance of !.

Obvious. Thanks. Re-instate the ! will be a little more tedious if there are more kinds of [[]]'s there.

That is true. Maybe you can save two versions of the file.