title: Pyspark string pattern from columns values and regexp expression
body: <p>Hi I have dataframe with 2 columns :     </p>
  
  <pre><code>+----------------------------------------+----------+
  |                  Text                  | Key_word |
  +----------------------------------------+----------+
  | First random text tree cheese cat      | tree     |
  | Second random text apple pie three     | text     |
  | Third random text burger food brain    | brain    |
  | Fourth random text nothing thing chips | random   |
  +----------------------------------------+----------+
  </code></pre>
  
  <p>I want to generate a 3rd columns with a word appearing before the key_word from the text.        </p>
  
  <pre><code>+----------------------------------------+----------+-------------------+--+
  |                  Text                  | Key_word | word_bef_key_word |  |
  +----------------------------------------+----------+-------------------+--+
  | First random text tree cheese cat      | tree     | text              |  |
  | Second random text apple pie three     | text     | random            |  |
  | Third random text burger food brain    | brain    | food              |  |
  | Fourth random text nothing thing chips | random   | Fourth            |  |
  +----------------------------------------+----------+-------------------+--+
  </code></pre>
  
  <p>I tried this but it's not working</p>
  
  <pre><code>df2=df1.withColumn('word_bef_key_word',regexp_extract(df1.Text,('\\w+)'df1.key_word,1))
  </code></pre>
  
  <p>Here is the code to create a example of the dataframe     </p>
  
  <pre><code>df = sqlCtx.createDataFrame(
      [
          ('First random text tree cheese cat' , 'tree'),
          ('Second random text apple pie three', 'text'),
          ('Third random text burger food brain' , 'brain'),
          ('Fourth random text nothing thing chips', 'random')
      ],
      ('Text', 'Key_word') 
  )
  </code></pre>