regex - Trying to accomplish similar functionality of .contains on an array of string using substring -


i have array of directory paths:

directory.getfiles(uploadpath) 

i want check array see if file exists in 1 of file paths. after looking @ of similar questions on so, came below. work except not match since file name substring of path in array. trying avoid loop.

if array.indexof(directory.getfiles(uploadpath), filename) > -1     'do cool coding stuff     exit sub end if 

my other thought getfiles method has searchpattern string parameter, guessing put regex there return value after last '\'.

so have works perfectly:

 if directory.getfiles(uploadpath, filename).length > 0      'do code stuff       exit sub   end if 

the searchpattern argument of getfiles doesn't take regex , matches against filename, wouldn't need fancy. call getfiles passing in directory name search first argument , filename looking second.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

keyboard - C++ GetAsyncKeyState alternative -

android - java.net.UnknownHostException(Unable to resolve host “URL”: No address associated with hostname) -