Personal tools
You are here: Home Reports Use Regular Expressions in Queries

Use Regular Expressions in Queries

by jack — last modified 2009-02-24 16:52

Power query building

The pre-processor in the query builder can do some nifty stuff. We're not talking full PCRE, but it's still able to use one or two useful things. This is a very handy thing for sites with strict naming conventions, so let's look at some examples:

  • Device Name begins with S, has two numbers, and then an A: "Computer"."Device Name" LIKE s[0-9][0-9]a*
  • Device Name begins with S or A or P, followed by any letter:
    "Computer"."Device Name" LIKE [s|a|p][a-z]*
  • Device Name ends with X or 42: "Computer"."Device Name" LIKE *[X|42]
  • Device Name begins with three letters, followed by an O: "Computer"."Device Name" LIKE [A-Z][A-Z][A-Z][O]*
  • The third octet in the IP address is 15: "Computer"."Network"."TCPIP"."Address" LIKE [0-9][0-9][0-9].[0-9][0-9][0-9].015.[0-9][0-9][0-9]
It doesn't appear to handle metacharacters or character classes though, even simple ones like . or +

, which is a bummer.

 

Remember, anything built in the query builder can be used as a scope or custom report, so have fun with it.

 

Server Says:
BOFH excuse #107:

The keyboard isn't plugged in
Safety First!
203 Days without a Dumpster fire.
 

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: