Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com)
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi
Tinderbox Users >> Agent, Actions, Rules & Automation >> Query - Match All Except the Set  Regex ^ Car
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi?num=1186969030

Message started by LarryB on Aug 12th, 2007, 9:37pm

Title: Query - Match All Except the Set  Regex ^ Car
Post by LarryB on Aug 12th, 2007, 9:37pm

I have an agent query which is not performing as expected

Query = #descendedFrom(Active Projects)&Prototype=@Project&TimeMatrix([ ^A-D])

Objective is to identify all Projects which have not been assigned a value of A,B,C,or D to the TimeMatrix attribute by gathering all notes from the Active Projects container, having a prototype of @Project and the TimeMatrix attribute can contain any character outside of the range capital A to D, including blank.

A space is required between the opening square bracket and the caret for the query to return any notes, but the query result returns the notes only matching the range A-D. I was expecting the opposite, notes having any character except the range A-D plus notes having no value assigned to the attribute.

I did attempt writing the query with a double caret  [ ^^A-D]  but this did not change the results in any way.

Have I created an incorrect expression or is this expression  outside the bounds of the query rules.

--Larry--



Title: Re: Query - Match All Except the Set  Regex ^ Car
Post by Mark Bernstein on Aug 12th, 2007, 11:15pm

I believe  you'll need (a) no extra space in the regex, and (b) a backslash to escape the caret (^), which (as I'm sure you know) has a special meaning in regular expressions.

My suggestion would be to find a way to simplify this agent, perhaps with an intermediate agent or rule.  You've got a lot of moving parts!

Title: Re: Query - Match All Except the Set  Regex ^
Post by Rob Hamrick on Aug 13th, 2007, 12:42pm

Larry:  Maybe you can tell us what the strings in your TimeMatrix attribute look like.  Are they single uppercase characters or are they longer strings?  Do they contain ^ characters?  Do they begin with a space?

Mark:  Is there maybe a bug with regular expressions here, or is it just me?  I'm finding that an agent that searches for Name(^[^a-z]) collects all the notes whose names do not begin with a-z, as it should, but an agent that searches for Name(^[^A-Z]) returns nothing.

Title: Re: Query - Match All Except the Set  Regex ^ Car
Post by LarryB on Aug 13th, 2007, 1:44pm

The valid values will be a single, uppercase A,B,C, or D, no spaces or caret characters. The query is to return notes not meeting these values, so I could review and update the attribute with a correct value.

I re-wrote the expression, adding the extra caret from your example, and tried a backslash  in various positions within the expression (fishing in the dark here), without success.

The theory for the regex expression makes for a very compact query, I'm just not able to get the results I expect.

thanks for the input,

--Larry--

Title: Re: Query - Match All Except the Set  Regex ^ Car
Post by Mark Anderson on Aug 13th, 2007, 2:13pm

Try \A as a the start of line anchor instead of ^, i.e. Name(\A[^A-D]). Seems to work for me.  As to why the other with 2 carets doesn't, I suspect TB is trying to work out is there's an export code called '[' (i.e. ^[^) in there. Sometimes there are never enough 'spare' characters to play with.

Working on the principle that TB uses the default BOOST regexp library implementation of Perl regexp syntax, the O'Reilly regexp books indicate \A is an alternative to ^. The two don't have exactly the same meaning but are close enough to work here - I think ! But I'd add I'm not a reg exp pro.

Title: Re: Query - Match All Except the Set  Regex ^ Car
Post by Mark Bernstein on Aug 13th, 2007, 2:45pm

How about


Quote:
Name(^(A|B|C|D)$)


This seems to work for me.

Title: Re: Query - Match All Except the Set  Regex ^
Post by Rob Hamrick on Aug 13th, 2007, 9:03pm

Actually, Name(^([^A-D])) works as well.  It seems like there might be something screwy with the ^[^ sequence when followed by an uppercase letter.

I'm not sure how this is related, but note that a query like Name(^[^A]) also produces unexpected behavior.  It gives the exact same results as Name(^[^a]), even though AgentCaseSensitive=true.  The query Name(^([^A])) works as it should, however.


Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com) » Powered by YaBB 2.2.1!
YaBB © 2000-2008. All Rights Reserved.