title: Regex to match all words that startswith and endswith specific characters in string
body: <p>How can I fix my regex pattern to match every word that startswith "X" and endswith "Z"?</p>
  
  <p>Code:</p>
  
  <pre><code>import re
  
  #input
  s = "xaz xazx xaxsza zsxdaszdx zasxz xaaz xaaaz"
  
  pattern1 = "x.*z"
  pattern2 = "\bx.*z\b"
  pattern3 = "x.*?z"
  pattern4 = "\b^x.*z$\b"
  pattern5 = "\Bx.*z\B"
  #also tried using \s, \S, ^ and $... 
  
  re.findall(pattern, s)
  </code></pre>
  
  <p>Desired Output:</p>
  
  <pre><code>out = ["xaz", "xaaz", "xaaaz"] 
  </code></pre>
  
  <p>How can I achieve this?</p>
  
  <p><a href="https://regex101.com/r/aGXyQP/1" rel="nofollow noreferrer">Regex Demo</a></p>