You are viewing limited content. For full access, please sign in.

Question

Question

regular expression to remove a section of name

asked on November 10, 2014

Goal:  WF token to rename an entry name by dropping the words "MARKED FOR ARCHIVE" (if those words should be in the entry name).

I am successful using [^"MARKED FOR ARCHIVE"]* in the Token Editor to get it to keep the first word in the entry name, but I want it to keep everything but "MARKED FOR ARCHIVE".

Also, first tried (.*) MARKED FOR ARCHIVE which seems to be bringing back "Entry not found" when I run the WF.  This expression also definitely doesn't work if the target words are not in the entry name, which is a problem.

What do I need to change to get it to keep everything but the targeted words?

In this test, it dropped the second word (which wasn't the goal).

Thx, Connie

0 0

Replies

replied on November 10, 2014

If you did want to use regular expressions the entire time, you could try using (.*)(?:MARKED FOR ARCHIVE)(.*), which will match any expression with Marked For Archive and only return the other parts of the string.

2 0
replied on November 10, 2014

[^ ] is actually excluding characters not in the specified range, rather than excluding the whole string the way you wanted it too.

You could check if it contains the string or not before you try to run pattern matching on it, but the most straightforward, though probably not the most obvious way to do it is to use token functions.

First, you can use Split and treat the whole "Marked for archive" string as delimiter. That will break the string apart and generate a multi-value token. For ex, "String MARKED FOR ARCHIVE test" becomes a token with 2 values "String " and " test". Then you want to trim the leading and trailing spaces so entries with just the beginning or end piece don't cause issues as WF renames documents. Then you can put the name back together with space as a delimiter using indexing.

 

1 0
replied on November 10, 2014

Ha, that seems to have worked!  Thank you!

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.