title: Replace a string using dictionary - regex
body: <p>I have a dictionary of slangs with their meanings and I want to replace all the slangs in my text. </p>
  
  <p>I have found partially working solution <a href="https://stackoverflow.com/a/2400577">https://stackoverflow.com/a/2400577</a></p>
  
  <p>For now my code looks like this:</p>
  
  <pre><code>import re
  
  myText = 'brb some sample text I lov u. I need some $$ for 2mw.'
  
  dictionary = {
    'brb': 'be right back',
    'lov u': 'love you',
    '$$': 'money',
    '2mw': 'tomorrow'
  }
  
  pattern = re.compile(r'\b(' + '|'.join(re.escape(key) for key in dictionary.keys()) + r')\b')
  result = pattern.sub(lambda x: dictionary[x.group()], myText)
  
  print(result)
  </code></pre>
  
  <p>Output: </p>
  
  <pre><code>be right back some sample text I love you. I need some $$ for tomorrow.
  </code></pre>
  
  <p>As you can see sings $$ haven't changed and I know it is due to <code>\b</code> syntax. How can I change my regex to achieve my goal?</p>