Link to home
Start Free TrialLog in
Avatar of Erwin Pombett
Erwin PombettFlag for Switzerland

asked on

how can i filter an arraylist with a regexp?

hello,

i need a group of files out of a directory D,
i put all files names contained in the directory D  into an arraylist,

now i need to filter the arraylist as i need only to keep the files that begin with a certain
string like "0001".

files in arraylist,
0001122.txt
0001123.txt
1001234.txt
......

i need to delete - in my arraylist - all the files that dont begin with a pattern of four numbers like here "0001",

in order to get
0001122.txt
0001123.txt.


thank you very much for help,
i would be delighted with some code,
SOLUTION
Avatar of Anurag Thakur
Anurag Thakur
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Erwin Pombett

ASKER


 sorry for the delay.....

I agree with you, thanks for the tip,
the thing is that i'm getting my files names through ftp with ftplib, and i dont have the possibility to
filter as you want me to filter,



this is how i recover the list of files,
if there's a possibility to do differently, without having all the files in the request , i would be happy,


   public ArrayList Get_FilesListFromFTP(string aPathToFTP, string anUser, string aPass)
        {
            DomainLayer.FTP ftpLib = new FTP();
            ArrayList _fileNameList = new ArrayList();
            try
            {
                ftpLib.Connect(aPathToFTP.ToString(), anUser, aPass);
                _fileNameList = ftpLib.ListFiles();
            }catch(Exception ex)
            {
                Console.Write(ex.Message);
            }

            return _fileNameList;
        }


thank you in advance,
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial