title: What is "unsafe" about this regex?
body: <p>I was trying to use the following regex in my JS code to find <code>~...~</code> blocks:</p>
  <pre><code>/(?&lt;!~)~([^~\n]+)~(?!~)/g
  </code></pre>
  <p>But then ESLint (<code>v7.22.0</code> configured to use eslint-plugin-security: <code>v1.4.0</code>, parser set to <code>ES10</code>, running on node.js: <code>v14.15.5</code>) gave me the following warning:</p>
  <pre><code>Unsafe Regular Expression  security/detect-unsafe-regex
  </code></pre>
  <p>So, I changed my regex to:</p>
  <pre><code>/([^~]|^)~([^~\n]+)~(?!~)/g
  </code></pre>
  <p>and it stopped giving me any warning. I also tested both of my regex on <a href="https://redos-checker.surge.sh/" rel="nofollow noreferrer">ReDoS Checker</a>, and the results were similar. But I cannot get what was possibly unsafe about the first regex that is not unsafe in case of the latter one.</p>
  <p>It is happening with two more regex which have used lookbehind functionality. Is there anything I should keep in my mind while using lookbehind assertions?</p>