c# - Select Files From Folder Depending on Name Convention -


i receive bunch of xml files in folder.

i want keep checking files have following naming convention:

sr-{first_id}-{second_id}-matchresults.xml 

to parse receive one.

for example:

sr-40-24-standings.xml sr-40-24-results.xml sr-40-24-j7844-matchresults.xml 

i should select 1 : sr-40-24-j7844-matchresults.xml

what comes after helps me select files depending on naming convention asp web service?

 dim files io.fileinfo() = foldername.getfiles("*.xml") 

private bool isvalid(string value)     {         string regexstring = "^sr-([a-z0-9]+)-([a-z0-9-]+)-matchresults.xml";         return regex.ismatch(value, regexstring);     } 

this method give files specified format (sr-{first_id}-{second_id}-matchresults.xml). note: ids can contain alphanumeric characters "-" symbol. if don't want symbol in id, code like,

string regexstring = "^sr-([a-z0-9]+)-([a-z0-9]+)-matchresults.xml"; 

Comments

Popular posts from this blog

java - BeanIO write annotated class to fixedlength -

Using Java 8 lambdas/transformations to combine and flatten two Maps -

How to connect android app to App engine -