regex name file

I would like to create a validation rule on an system filedocument entity that check the type of the file. For security reason. I only see that the name is available in the entity, so I thought that maybe i could retireve the lasts characters, and check if the value correspond to what I want (for example pdf txt jpeg ...)  The only way to do that seems to put a regular expression. Which I am not an expert. Maybe someone can tell me if this is possible? and maybe help me with the regex, for example :  the last 4 digit equal .txt, or last 5 digit equal .jpeg Thanks!
3 answers

Answer on this question is given here:


For getting and testing a regex there are great online tools available. For instance and

This regex will match you the file-extensions:


The AppStore widget ‘File dropper’ has a setting that limits the imported files to only the file-extensions you specify:


Hey Yehoshoua,


After reviewing my answer given on, I found a more secure RegEx that checks the file format better:



My previous regular expression only checked the file format value, and not if it was an actual file format extension. For example, with the old RegEx ‘.*(txt$|jpeg$|png$|pdf$|jpg$)’ both 'filename.txt’ and 'filenametxt’ would match the RegEx. With the new RegEx, only 'filename.txt’ would match.


Kind regards,