title: substring from lastIndexOf in spark scala
body: <p>I have a column in my dataframe which contains the filename </p>
  
  <pre><code>test_1_1_1_202012010101101
  </code></pre>
  
  <p>I want to get the string after the lastIndexOf(_)
  I tried this and it is working </p>
  
  <pre><code>val timestamp_df =file_name_df.withColumn("timestamp",split(col("filename"),"_").getItem(4))
  </code></pre>
  
  <p>But I want to make it more generic, so that if in future if the filename can have any number of _ in it, it can split it on the basis of lastIndexOf _</p>
  
  <pre><code>val timestamp_df =file_name_df.withColumn("timestamp", expr("substring(filename, length(filename)-15,17)"))
  </code></pre>
  
  <p>This also is not generic as the character length can vary.</p>
  
  <p>Can anyone help me in using the lastIndexOf function with withColumn.</p>