andreasc
Design Dabbler

Extracting text from filename

Jump to solution

Hi,

 

I have a document library that i have the below extra columns:

1. Groupname (text)

2.Type (text)

3. Location (text)

4. Date (Date only)

When a user uploads a file the above columns should be updated based on the extracted text from the filename.

 

I'm trying to extra the text from filename that is separated by "-" symbol.

My filename will have the following format:

Groupname-Type-location-date.pdf (extension can be docx or any other file extension)

Date will be in format: ddmmyy (no symbols in between)

 

I was able to extract the first & second part but not the rest.
1. For the first part (GroupName)i use the below code:

(^.*?(?=-))

2. For the second part (Type) i used the below code:

(?<=-)[\w ]+(?=)

 

Any body can help me how to extra the rest 3rd and 4th part?

I'm not sure if it's correct but for each part i'm using a separate "regular expression" box in nintex workflow.

 

nintex.JPG

Thanks

0 Kudos
Reply
6 Replies
leighburke
Nintex Employee
Nintex Employee

Re: Extracting text from filename

Jump to solution

@andreasc It may be easier to first do a split function, then you will have each part as an item in the collection and you will just have to remove the file type from the last entry using regex.

Workflow Designer - Internet Explorer.png

 

Reply
andreasc
Design Dabbler

Re: Extracting text from filename

Jump to solution
Thanks for your reply.
How i can recognize which part after splitting so i can store it in separate variable?
0 Kudos
Reply
leighburke
Nintex Employee
Nintex Employee

Re: Extracting text from filename

Jump to solution

@andreasc The split will always split in order into your collection variable, so groupname would be index 0, type index 1 and so on.

View solution in original post

Reply
andreasc
Design Dabbler

Re: Extracting text from filename

Jump to solution
thanks for your solution.
I have a small issue removing the file extension from the last part.
I'm using: [^/]*(?=\.[^.]+($|\?)) for extracting the filename but i'm getting the symbo ";" at the end .
For example my file is: filename.docx
The result is: filename;
is it possible to fix this issue without the need to create another variable removing the ";" symmbol?
0 Kudos
Reply
leighburke
Nintex Employee
Nintex Employee

Re: Extracting text from filename

Jump to solution

Hi @andreasc,

 

Just need to try another regular expression method, try a replace text operation with \..*$ instead.

Reply
andreasc
Design Dabbler

Re: Extracting text from filename

Jump to solution
@leighburke Thanks alot .. it worked!!
0 Kudos
Reply