Filtering a list of documents - Already developed somewhere?


I have the following development to do but believe that this must already exist somewhere.

I need to create a generic filter for a list of documents. The filter needs to work for the wild cards ‘*’ (represents >1 character)and ‘?’ (represents a single character).

Surely this must have already been developed.

Any helpers

Thanks in anticipation

hmm… is it a fixed filter string? Because a simple loop with branch and append to document list would do it:

MAP (initialise empty output list)
LOOP (list of docs)
  BRANCH (switch variable set to variable check filter against)
     (label=/regularExpresionHere/) INVOKE (appendToDocumentList (add to output list)

There’s a guide on using regular expressions in the appendicies of the Developers guide pdf doc. Roughly if you wanted to match *hello? you could use
/^.*hello.$/ (^ means start of the string, $ means end of String, the forward slashes mean that the label is a regex)

But if you need to have the filter dynamic, then java has regular expression matching code, a simple replace of “" with ".” and “?” with “.” escaping of any special characters (like full stops) before you do that substitution, so would be a little painful… You can write a java service to determine whether something matches.

The PSUtilities package has the snippet of code that does regex matching in the

You’ll also need a service that pulls a given field’s value from the pipeline, you can do that with and feed in %value PATHTOVARIABLEHERE% as the $template input. Nice and easy then… Just wrap it up to make it nice.

So grab the psutilities regex code and then just build a service that:

1. escapes special characters in the wildcard string
2. substitutes "*" with ".*" and "?" with "."
3. loops over the doc list
4.    retrieves the pipeline variable you're wanting to check (see my above suggestion on how to do this without too much work)
5.    calls PSUtilities.regex:matches or equivalent on that variable
6.    branch on whether it matched
7.       true : appendToDocumentList (the output list)

Might be able to do something with using regular expressions and the queryXMLNode to pull out what you want…? But that’s always seemed awkward to me…

Sorry I don’t have a completely pre-packaged answer, but it wouldn’t take too much code to do it, but like you said: surely someone’s developed it… I haven’t had the need unfortunately…

Nathan Lee