title: Applying re.search function to column in Python
body: <p>I have the following Python code (I want the first match of a specific number in a text field):</p>
  
  <pre><code>import numpy as np
  import pandas
  
  data = {'A': [1, 2, 3], 'B': ['bla 4044 bla', 'bla 5022 bla', 'bla 6045 bla']}
  df = pandas.DataFrame(data)
  
  def fun_subjectnr(column):
      column = str(column)
      subjectnr = re.search(r"(\b[4][0-1][0-9][0-9]\b)",column)
      subjectnr1 = re.search(r"(\b[2-3|6-8][0-9][0-9][0-5]\b)",column)
      subjectnr = np.where(subjectnr == "" and subjectnr1 != "", subjectnr1, 
      subjectnr)
      return subjectnr1
  
  df['C'] = df['B'].apply(fun_subjectnr)
  </code></pre>
  
  <p>Wanted output:</p>
  
  <pre><code> A    B                C
   1    bla 4044 bla    4044
   2    bla 5022 bla    None
   3    bla 6045 bla    6045
  </code></pre>
  
  <p>It doesn't seem to work. When I add a [0] to the regex code, it gives an error...(subjectnr = re.search(r"(\b[4][0-1][0-9][0-9]\b)",column)[0])</p>
  
  <p>Who knows what to do? Thanks in advance!</p>