String must contain a specific character once : <p>When writing a regex I only know how to specify what is ALLOWED to be in a string, but I don't know how to specify what MUST be in it.</p>

<p>Let's say I need a regex that validates e.g. a sentence that contains exactly one <code>$</code> character anywhere.</p>

<pre><code>"This $ should validate."
"This shouldn't validate."
"This $ should not $ validate either."
</code></pre>

<p>How to do that?</p>
