Extract file extension from filename

Hi, I need some help with Regex. I’m trying to write an expression that extracts the file extension for a file being uploaded. So for e.g.

  • Sample.pptx should extract .pptx
  • Sample.pdf should extract .pdf
  • Sample.doc should extract .doc

(the extension could be four or five characters .doc or .docx including the period)

I tried passing the filename into the expression and used the Extract with Regex operator
but the custom state I pass this value into is blank. I tried extracting and saving (what I thought would be) the extracted text to the database and that’s blank too.

Could use any help on how to accomplish this.


Hi there, @SeanB… have you tried using the :split by operator, with the character to split by being a period, and then get the last item in the split? That should work.

Hope this helps.



Thanks, Mike. Great suggestion. That never occurred to me. I did a :split by and then get the extension as the last item in the split.

I then when and added a period before that expression to get a .pdf, which is just what I wanted.

Thanks so much once again.

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.