Pulling policy number from folder name

Hi,

I am currently automating a document upload job, one of the required pieces of info when uploading is the Policy number. I have broken down each drive to all its individual subfolders in order to upload separately. The second highest level folder usually looks like the below:

ABC2000345 - Joe Bloggs

What I need to do is pull the ABC2000345 part of the name and print this to my Policy Number Column in my Master SS.

Any ideas??

By using Regex Expression you can get it

System.Text.RegularExpressions.Regex.match(YourString,".*(?=\s-)").tostring.trim

image

Otherwise use String Split method,

YourString.Split("-")(0).tostring

HI @Sean_Ryan1

You can try with Regex expression

System.Text.RegularExpressions.Regex.Match(YourString,"\S+(?=\s-)").Tostring

image

Regards
Gokul

You can also try with Split expression @Sean_Ryan1

Split("ABC2000345 - Joe Bloggs","-")(0)

image

Regards
Gokul

Hi @Sean_Ryan1 You can do a Split on the name of file. from what I see you have a hyphen(-) in the name so say your filename/folder name is stored in a variable(str) then str.split("-"c)(0).Trim. This will give you the required string.

Used this in a assign activity

cheers

You don’t have to use it in an assign. You can use the expression anywhere. Often, assigning to a variable is pointless extra work. Just directly use the expression where you need it.

Hi @postwick ,

I agree, mentioned it because if she needs in other places she can use directly instead of repeating split again

cheers