Skip to main content
Nintex Community Menu Bar
Solved

Regular Expression - Extract text between 2 characters in document filename

  • February 10, 2022
  • 2 replies
  • 578 views

Forum|alt.badge.img+4

I'm trying to extract part of a filename, everything after " - " and before the " .pdf ":
3114062-123456789.pdf

I'm using this expression:

(?<=-).*(?=.pdf)

It works, except that it always includes a " ; " at the end when I insert it into SharePoint.

How do I get rid of the  " ; "

 

Best answer by mlauer

With extract, the result is written to a collection. You have connected this collection variable to a SharePoint column. This is the reason for the semicolon at the end. Either you assign the 1st element of the collection to a single line text variable and store it in the list or you use the operation replace text instead of extract. Here the result is assigned to a single line text variable, which can be stored in the list. You can use ^[^-]*-(.*).pdf$ as pattern and $1 as replacement text.

2 replies

Forum|alt.badge.img+9
  • Answer
  • February 11, 2022

With extract, the result is written to a collection. You have connected this collection variable to a SharePoint column. This is the reason for the semicolon at the end. Either you assign the 1st element of the collection to a single line text variable and store it in the list or you use the operation replace text instead of extract. Here the result is assigned to a single line text variable, which can be stored in the list. You can use ^[^-]*-(.*).pdf$ as pattern and $1 as replacement text.


Forum|alt.badge.img+4
  • Author
  • Rookie
  • February 14, 2022
Awesome, using the operation replace text and your pattern worked! Thank you so much.