Pattern matching only for string


I have a folder containing multiple files. Theses files are named in the format - [company name dd-mm-yy]. I want to retrieve the name of all these files without the date in it. I want to extract only the alphabets not the date.

How do I do it?

Hi @praveenM1

use Strarry=Directory.GetFiles(InputFolderpath)

use regex pattern and use matches activity


Ashwin S

Can you please share the sample file name for reference.

Company name will contain any numeric value?

hi @AshwinS2, @karthick

your solution gives the date present in the filename. Iwant only the company name.

Yes the company name has numeric values

Sample file name pls


Input Files are :
Wipro 18-02-20
3M Company 19-02-20
Tata Consultancy Services 19-02-20.

Expected OuTPUT:
3M Company
Tata Consultancy Services

Split the files name wrt to space and ignore last index . That solves

Eg: 3M Company 19-02-20

If you split this index (0) and (1) will contain company name and (2) will have date .

Ignoring index (2) and appending it with other list of value solves

(0)+" "+(1)

check this link i’ve tried with regex!
it’s working fine for me


Hi Praveen,

/*Use the following Regex */ 


  1. Get the File Paths
  2. Use For Loop
  3. Inside For Loop - Matches Activity with the Regex I Provided Above
  4. Inside For Loop - Get Match as RegexMatchVariable(0).Groups(1) - Which will give the Company Name

Thanks and Regards,
Ranjith Udayakumar

1 Like

Use Regex also to filter the files if you want . I have used
(.)\d{2}-\d{2}-\d{4} - Wipro 18-02-2020
)\d{2}-\d{2}-\d{2} - Wipro 18-02-20

Kindly add Star next to dot

(.*)\d{2}-\d{2}-\d{4} - Wipro 18-02-2020
(.*)\d{2}-\d{2}-\d{2} - Wipro 18-02-20

Yep… Missed it

(.)\d{2}-\d{2}-\d{4} - Wipro 18-02-2020
)\d{2}-\d{2}-\d{2} - Wipro 18-02-20

Try this :slightly_smiling_face: