RegEx help for excel file names

I have the following files, i need to capture the A00180 from each string, this is a dynamic file name that will change. I need a regex that will work with both strings, where the number between - - can be a single or double-digit. This regex will work for single-digit (?<=ADL\sOrderbook - \d - )(.*)(?=.xlsx) but I am struggling to change it to work for both files.

ADL Orderbook - 2 - A00180.xlsx
ADL Orderbook - 12 - A00180.xlsx

Hi @David_Bishop

Can you share the Exact output

Regards
Gokul

Hi,

How about the following expression?

System.Text.RegularExpressions.Regex.Match(yourString,"(?<=ADL\sOrderbook - \d+ - )(\w*)(?=\.xlsx)").Value

Regards,

Hi @David_Bishop

You can try with Regex Expression

Use Assign Activity
LHS → Create an variable (Test1)
RHS → System.Text.RegularExpressions.Regex.Match(yourString,“(?<=ADL\sOrderbook - )\d{1,2} - (.*)(?=.xlsx)”).Tostring

Use Assign Activity
LHS → Create an variable (Test2)
RHS → Split(Test1,"- ") (1)

Regards
Gokul

here are some of the file names. this may help

ADL Orderbook - 12 - AEF01.xlsx
ADL Orderbook - 5 - Z92151.xlsx
ADL Orderbook - 12 - A00750.xlsx
ADL Orderbook - 2 - W88550.xlsx

What kind of output do you expect ?

I am trying to capture the following information from the string.

AEF01
Z92151
A00750
W88550

Hi @David_Bishop

Try like the above post it will solve your query

image

Regards
Gokul

2 Likes

ok, thanks, i will give it a go.

thank you for your help :slight_smile:

David

Let me know if you face any issue @David_Bishop

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.