title: regular expression code size limit exceeded python
body: <p>I'm using a dict file and Regular Expressions to change some words in a script but have now come across this error</p>
  
  <blockquote>
    <p>Exception caught in plugin &lt; class 'pagerprinter.plugins.tts.TTS' ><br>
        regular expression code size limit exceeded</p>
  </blockquote>
  
  <p>my dict has some 5300 entries long set out as:</p>
  
  <pre><code>'SE': 'South East',
  'NE': 'North East',
  </code></pre>
  
  <p>You get the idea changing abbreviations to full words. on average 6 - 8 abbreviations are changed.</p>
  
  <p>for this I'm using</p>
  
  <pre><code>from abbreviations import abbreviations #mydict
  pattern = re.compile(r'\b(' + '|'.join(abbreviations.keys()) + r')\b')
      msg = pattern.sub(lambda x: abbreviations[x.group()], msg)
  </code></pre>
  
  <p>but I also use a further 4 more regexes for other tasks like removing words and numbers from the a number of strings.</p>
  
  <p>What is the cause of the error I get? if I remove my dict it works if I have 300 entries it works.</p>
  
  <p>looking into it from Google most people say that there are no limits on dict sizes. </p>