title: Regex: Slack-like 'markdown' for matching exactly one formatting character
body: <p>I've tried researching this but could only figure out how to make my search terms so precise.</p>
  
  <p>I want the user to be able to surround text with symbols, <code>_</code>, <code>*</code>, <code>~</code>, etc. for markdown-like formatting, basically the way Slack does it. I got it working pretty well, but I have one issue.</p>
  
  <p>When the user types <code>_bold_</code>, I render <code>&lt;strong&gt;bold&lt;/strong&gt;</code>, which is the desired effect. But when the user types <code>__bold__</code>, I get <code>&lt;strong&gt;_bold_&lt;/strong&gt;</code> when I would rather just get <code>__bold__</code>.</p>
  
  <p>Here's my regex:</p>
  
  <pre><code>const rules = [
      {regex: /_{1}(.+?)_{1}/g, replacement: '&lt;em&gt;$1&lt;/em&gt;'},
      {regex: /\*{1}(.+?)\*{1}/g, replacement: '&lt;strong&gt;$1&lt;/strong&gt;'},
      // etc
  ];
  </code></pre>
  
  <p>Then I'm running:</p>
  
  <pre><code>let formattedText = '__some text__'; // the user input
  rules.forEach(rule =&gt; formattedText = formattedText.replace(rule.regex, rule.replacement));
  </code></pre>
  
  <p>It matches only the one with <code>{1}</code>. But how do I make it ignore cases where there are multiple?</p>