Painless Script: Splitting a string by '/'

Hello, Here's my scenario. I have an index full of documents. I'm trying to create a new field called parent_folder_path which will be based on the already existing path field. For example, if path is populated by example/file/path/document.pdf, the parent_folder_path would be example/file/path/.…