title: Regex to find a pattern repeating at least n times
body: <p>I'm being destroyed by spam and the emails are always different except that they always have similar links like this that repeat several times:</p>
  
  <blockquote>
    <p><a href="http://spam.com/hello/world/fk59j356jss5ptttNMdlJ96vmrDsjEeCPDXJf0fBXOi" rel="nofollow">http://spam.com/hello/world/fk59j356jss5ptttNMdlJ96vmrDsjEeCPDXJf0fBXOi</a></p>
  </blockquote>
  
  <p>So I'm trying to put a filter on my server that will scan a slash followed by 30-50 alphanumeric characters, which will then repeat at least 3 times. I wrote the following regular expression but on regex101.com,I keep getting a "timeout" message, probably because there is a better way to write it:</p>
  
  <pre><code>/(\/\w{30,50})(.+?\1){3,}/s
  </code></pre>
  
  <p>I tried google but my search terms never returned what I wanted.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Here's the link so you can see:
  <a href="https://regex101.com/r/tL9wK7/2" rel="nofollow">https://regex101.com/r/tL9wK7/2</a>
  We can identify the spam link with this part that always repeats:</p>
  
  <p>/bcaip86eJR2W5hKmMjFiKVWmKyLjmiMKhkOm0Mjh906</p>
  
  <p>There is always something similar in the spam emails (a slash followed by a series of alphanumeric characters). This link is different in every spam email but it will repeat multiple times in the same email.</p>
  
  <p>So scanning in an email if there is a link with a slash followed by 30-50 alphanumeric characters that appears several times in the same email will reveal that it is spam.</p>