Skip to main content
Nintex Community Menu Bar

Extracting text from filename

  • April 14, 2020
  • 6 replies
  • 71 views

Forum|alt.badge.img+1

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.

 

7296iA378E91D73FF31A2.jpg

Thanks

6 replies

Forum|alt.badge.img+14
  • Nintex Employee
  • April 14, 2020

@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.

7297iBDBBC59D2AD71E35.png

 


Forum|alt.badge.img+1
  • Author
  • April 18, 2020
Thanks for your reply.
How i can recognize which part after splitting so i can store it in separate variable?

Forum|alt.badge.img+14
  • Nintex Employee
  • April 21, 2020

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


Forum|alt.badge.img+1
  • Author
  • May 13, 2020
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?

Forum|alt.badge.img+14
  • Nintex Employee
  • May 13, 2020

Hi @andreasc,

 

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


Forum|alt.badge.img+1
  • Author
  • May 14, 2020
@leighburke Thanks alot .. it worked!!