Im trying to set a validation for not repeated file names, if some file is repeated it should be writen this way:
- FILENAME.PDF
- FILENAME_1.PDF
- FILENAME_2.PDF
So I can make the first one, but all the rest how can be taken?.
I will get a list of all filenames documents before, so now im trying to make like a for each document but i dont know how to make regex for get it.
FILENAME_1.PDF -> REGEX() -> GET RETURN -> 1
UPDATE
If I have this files in my bbdd: [filename.pdf, filename_1.pdf, filename_2.pdf].
I need when someone upload some new, based on that files, my new name will be filename_3.pdf if exist file name 2.
FILENAME_VERSION.EXTENSION
Base on this i need get the version of the last filename. Thanks!
Note: There will be more filesnames differents, for example FILANEM_FILENAM_VERSION.pdf
Thanks you!