title: Extracting substring in python string using regular expression
body: <p>I have a pandas column like this: </p>
  
  <pre><code>LOD-NY-EP-ADM
  LOD-NY-EC-RUL
  LOD-NY-EC-WFL
  LOD-NY-LSM-SER
  LOD-NY-PM-MOB
  LOD-NY-PM-MOB
  LOD-NY-RMK
  LOD-NY-EC-TIM
  </code></pre>
  
  <p>I want the output in new column as </p>
  
  <pre><code>EP
  EC
  EC
  LSM
  PM
  PM
  RMK
  EC
  </code></pre>
  
  <p>I tried this: </p>
  
  <pre><code>pattern=df.column[0:10].str.extract(r"\w*-NY-(.*?)-\w*",expand=False)
  </code></pre>
  
  <p>While it works for everything but it fails to get RMK out and gives NaN since there is nothing after that and it looks for -\w zero or more times. But then that should work if there is nothing after RMK. </p>
  
  <p>Any idea whats going wrong? </p>
  
  <p>We can just use a array of these and use regular expression if pandas syntax is not familiar. </p>