So I'm trying to query a table based upon the name of a document, however, I need to clean up the documents name first as the names when I bring into Laserfiche are renamed with the (1), (2), etc. Below is what the document names look like...so I'm trying to find out if 1) Do I need to clean them up first and if that can be automated so that I can drop the _2, _3, etc. and the (1), (2), (3). So documents can have numbers in the name, but never with the underscore or parenthesis or can I do some type of query that matches part of the entry name and the page count?
Question
Question
Cleaning up name to do a query?
Answer
That's odd, it works for me.
Could it be a version issue? We're running Workflow 9.1.1.365.
Replies
Another (simpler) regex that will remove your extra characters:
([^_(]+).*
Match anything but underscore or open parenthesis one or more times followed by zero or more characters.
The base file name should be stored into the first capture group.
This does assume that there are no underscores or parentheses anywhere in your file names. You can add characters to the negated character class to include other characters that will never appear in your file names (perhaps period?). The regex does capture trailing spaces, but that can be fixed either by altering the regex slightly or running the file names through a string trim.
You can do a single regular expression that will return the "core" document name.
(.+)(?=_\d+|\s\(\d+\))|(.+)(?!_\d+|\s\(\d+\))
Here's a description of what it's doing:
In my tests this strips off (1) and _1 and leaves the rest of the string intact.
Devin,
For whatever reason, I cannot get the "31" in the following name to appear which is breaking one of my queries: 11030 plans tif Created 3 6 2013 9 18 31.
The Regex you provided is working great...but doesn't pick up the 31?
Thanks!
That's odd, it works for me.
Could it be a version issue? We're running Workflow 9.1.1.365.
Got it...I had a (?=\s+\d+| instead of (?=_\d+|
Thanks!!
Hi Daryl,
If your question has been answered, please let us know by clicking the "This answered my question" button on the appropriate response.
If you still need assistance with this matter, just update this thread. Thanks!
I'm still having some issues with the Regex which is why I did updated the thread. Thanks