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

Question

Question

Regular Expression in the Advanced Search

asked on January 7, 2015

Hello,

I am looking to place a constraint on one of our commonly used fields. [^a-z,-,\s]+

 

Essentially, the value would need to be all upper case, not have any dashes or spaces, but could be as long as required. My tests show this to be successful.

 

Now I'm wanting to find all documents in our repository that don't fit this format to make corrections before I apply this constraint to the field, and I'm not quite sure how to do so.

 

I did attempt several searches using the Advanced Search functionality, and I saw a thread that touched on using the Regex in the advanced search. Essentially I tried "[Client Number]="[^a-z,-,\s]+" and several variations of this (Client Number is the field I'm working on).

 

Currently on Laserfiche 8.3.

 

0 0

Answer

SELECTED ANSWER
replied on January 8, 2015 Show version history

The only method I came up with to perform searches for each of those cases involves leading and trailing wildcards, which is an inefficient way to search, but the following should work as the values in your field search:

1) If you change the non-indexed search option for case sensitivity to be case sensitive, you can use the following: *[abcdefghijklmnopqrstuvwxyz]*

You must list out the letters rather that doing [a-z] because that wildcard will match both upper and lowercase letters.  Option for changing the search can be found here:

2) * *

3) *-*

 

To perform these all as one search, you would run the following:

{[YourTemplateName]:[Client Number]="*-*"} | {[YourTemplateName]:[Client Number]="* *"} | {[YourTemplateName]:[Client Number]="*[abcdefghijklmnopqrstuvwxyz]*"} 

If the field is not part of the template, simply leave that blank like {[]:[Client Number] = "* *"}

Edit:  Or, more simply, you could combine them all into the bracket wildcard (escaping the dash) like so: *[abcdefghijklmnopqrstuvwxyz \-]*

1 0

Replies

replied on January 7, 2015

You could create a workflow to simulate this behavior: Search Repository to find all documents ( {LF:Name="*", Type="DB"} ), then retrieve the field value and apply your regular expression to it. If there is a match, create a shortcut to it in a new failure folder. 

regexbruteforce.png
3 0
replied on January 7, 2015

It might be this thread. Note that it mentions wildcards and character ranges. However, that's the extent in which you can get regex like behavior in the advanced search. For example, the + character won't be interpreted as a quantifier.

2 0
replied on January 7, 2015

This doesn't help for LF 8.3, but in 9.0+ if you attempt to apply constraints to a field where some documents have values that do not match the constraint, the administration console will include the number of problematic documents, and the full file path to the first document.

Example:

Are there particular constraint violations you are worried about? If so, we may be able to help you construct specific searches for those situations.

1 0
replied on January 8, 2015

Essentially I want to find all documents that contain:

1) Lower Case letters

2) Spaces

3) Dashes

 

Once found I would then go through and modify these items to conform to the pattern we want to apply. I'm thinking that doing this should be faster via the search function than setting up a workflow as shown by Kevin. Although I will start looking into that as well.

0 0
SELECTED ANSWER
replied on January 8, 2015 Show version history

The only method I came up with to perform searches for each of those cases involves leading and trailing wildcards, which is an inefficient way to search, but the following should work as the values in your field search:

1) If you change the non-indexed search option for case sensitivity to be case sensitive, you can use the following: *[abcdefghijklmnopqrstuvwxyz]*

You must list out the letters rather that doing [a-z] because that wildcard will match both upper and lowercase letters.  Option for changing the search can be found here:

2) * *

3) *-*

 

To perform these all as one search, you would run the following:

{[YourTemplateName]:[Client Number]="*-*"} | {[YourTemplateName]:[Client Number]="* *"} | {[YourTemplateName]:[Client Number]="*[abcdefghijklmnopqrstuvwxyz]*"} 

If the field is not part of the template, simply leave that blank like {[]:[Client Number] = "* *"}

Edit:  Or, more simply, you could combine them all into the bracket wildcard (escaping the dash) like so: *[abcdefghijklmnopqrstuvwxyz \-]*

1 0
replied on January 8, 2015

That query worked perfectly. As you noted it was a bit slow, but the results were exactly what I needed.

 

Thanks!

0 0
replied on January 7, 2015

Could you include the link to the thread that had the advanced search functionality?

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

Sign in to reply to this post.