1
0
-1

Hello All.

When uploading a file using the Google Drive plugin (we are on Joget Cloud - DX8), how can we check that the filename is valid and, if not, return an error upon the completion of the upload?

For example, given the screenshot below:

We want it so that the file titled screenshot-2023-11-24 103352.png is not flagged with an error, whereas the filename below (which has image but followed by symbols) should be flagged as not valid, despite also being .png.

We tried adding this regex to the file upload control, but it doesn't seem to work:

^(?!_)[\x21-\x7E\u0E00-\u0E7F\u0E50-\u0E59]{1,250}$

What happens is that, as you can see from the above screenshot, it flags both uploaded files, which is not correct.

We need the filenames to only be accepted based on the following:

ASCII characters only: 
Underscores permitted but not as the first character
Maximum length of 250 characters
Thai characters and numbers

Any help is much appreciated - thank you.

    CommentAdd your comment...

    2 answers

    1.  
      2
      1
      0

      The following answer is from ChatGPT, do try it in future for yr technical questions if they are generic programming questions:

      The following regular expression should satisfy your requirements:

      regex
      ^(?!_)[\x20-\x7Eก-๙0-9_]{1,250}$

      Explanation:

      • ^: Asserts the start of the string.
      • (?!_): Negative lookahead assertion to ensure that the filename does not start with an underscore.
      • [\x20-\x7Eก-๙0-9_]: Character class that allows ASCII characters (excluding control characters), Thai characters, numbers, and underscores.
      • {1,250}: Specifies that the length of the filename should be between 1 and 250 characters.
      • $: Asserts the end of the string.

      This regex allows ASCII characters (excluding control characters), Thai characters, numbers, and underscores. It ensures that the filename does not start with an underscore and enforces a maximum length of 250 characters.

      1. Ian Walker

        Thank you very much for this.  We got it working.

      CommentAdd your comment...
    2.  
      2
      1
      0

      Hi, you might want to refer to resources for regex like https://stackoverflow.com/questions/38615740/regular-expression-to-accept-all-thai-characters-and-english-letters-in-python. You can also try some regex testing tools like https://www.regextester.com/116401.

      1. Ian Walker

        Thank you very much for your guidance pointing us to the right direction.

      CommentAdd your comment...