cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

regex extension filename

Jump to solution


How is it possible to cut off the file extension from a name.

 

What we are willing to do is the following:

User creates a docx file and will be converted to a pdf.

In the approval screen (nintex forms) we want to show the pdf instead of the docx with the pageviewer.

to do this, we need to put in a variable the documentname.pdf instead of documentname.docx

Tags (2)
Reply
2 Replies
Automation Master
Automation Master

Re: regex extension filename

Jump to solution

If the filename always has .docx in the end, then it is very simple.

Configure the Regular Expression action with the Pattern ".docx", Operation to Replace text, set the replacement text to "", have the input text as the filename(by reference), and store the result in a single line of text variable.

 

regex.PNG

 

The result here will be "filename".

 

If the file extension is not always .docx, then you will need to replace the pattern with a regex that looks for the final dot and anything after it to make a match.

View solution in original post

0 Kudos
Reply
Automation Master
Automation Master

Re: regex extension filename

Jump to solution

I've found that the pattern

[^/]*(?=\.[^.]+($|\?))

will find the filename every time. So using this function with operation "Extract" and saving to a collection.

so "fil en.ame.docx" will result in file en.ame;

and "file.name.docx" will result in file.name

and "file.name.txt" will result in file.name

0 Kudos
Reply