Unfortunately, that is not possible to do with Regular Expressions (RegEx) code because of how this PHP function works: file_exists()
Question to AI: Can you use regular expressions for the path for the php file_exists function?
AI response: No, the PHP file_exists function does not support regular expressions for its path parameter. It accepts a single, literal path string to a specific file or directory.
I could use coding methods like AI is suggesting below to scan all directories for files named: error_log, put the error_log file paths into an array, store that array information in the WP DB and then output the DB data in form that would allow excluding all files named error_log in one Form submission. Unfortunately, I don’t have that kind of time to spare on BPS Pro these days. I’ve been working on other coding projects these days. Mainly focusing on AI Dev these days. So yeah unfortunately, there is no quick and easy solution for this.
To check for the existence of files matching a regular expression pattern, you must:
Scan the directory to get a list of all file names using a function like scandir().
Iterate through the list and use a regular expression matching function like preg_match() to test each file name against your desired pattern.
Alternatively, you can use the PHP glob() function, which uses shell wildcards (not full regular expressions) to return an array of file paths matching a pattern. If the resulting array is not empty, it means at least one file matching the wildcard pattern exists.