title: Pandas Strip Characters Left and Right Using Wildcards
body: <p>I&quot;m trying to remove characters in a df column left and right of key words that keep repeating in rows of a large DF. There are leading numbers too that change so it's not so easy. My data looks like this:</p>
  <pre><code>128544  20210831  2200    882.2          342259.UNITED STATES.LAKERS.NBA.csv
  128545  20210831  2300    918.9          342259.UNITED STATES.LAKERS.NBA.csv
  128546  20210901     0      NaN          544257.UNITED STATES.CELTICS.NBA.csv
  128547  20210901   100      NaN          544257.UNITED STATES.CELTICS.NBA.csv
  </code></pre>
  <p>I need the stripped character DF &quot;df&quot; to look like this:</p>
  <pre><code>        col1      col2    col3           col4
  128544  20210831  2200    882.2          LAKERS
  128545  20210831  2300    918.9          LAKERS
  128546  20210901     0      NaN          CELTICS
  128547  20210901   100      NaN          CELTICS
  </code></pre>
  <p>I've tried -
  df['col4'] = df.col4.str.replace(&quot;.NBA).*&quot;,&quot;&quot;)</p>
  <p>and it gives me the right half but I cannot see how to strip the left side or do both at the same time.</p>
  <p>Thank you for your help,</p>