Welcome, Guest. Please Login
Tinderbox
  News:
IMPORTANT MESSAGE! This forum has now been replaced by a new forum at http://forum.eastgate.com and no further posting or member registration is allowed. The forum is still accessible via read-only access for reference purposes. If you wish to discuss content here, please use the new forum. N.B. - posting in the new forum requires a fresh registration in the new forum (sorry - member data can't be ported).
  HomeHelpSearchLogin  
 
Pages: 1
Send Topic Print
Query - Match All Except the Set  Regex ^ Car (Read 16758 times)
LarryB
Full Member
*
Offline



Posts: 6

Query - Match All Except the Set  Regex ^ Car
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--


Back to top
 
 
  IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: Query - Match All Except the Set  Regex ^ Car
Reply #1 - 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!
Back to top
 
 
WWW   IP Logged
Rob Hamrick
Full Member
*
Offline



Posts: 11
Oakland/Berkeley, CA
Re: Query - Match All Except the Set  Regex ^
Reply #2 - 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.
Back to top
 
 
  IP Logged
LarryB
Full Member
*
Offline



Posts: 6

Re: Query - Match All Except the Set  Regex ^ Car
Reply #3 - 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--
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Query - Match All Except the Set  Regex ^ Car
Reply #4 - 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.
Back to top
 
« Last Edit: Aug 13th, 2007, 2:49pm by Mark Anderson »  

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: Query - Match All Except the Set  Regex ^ Car
Reply #5 - Aug 13th, 2007, 2:45pm
 
How about

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


This seems to work for me.
Back to top
 
 
WWW   IP Logged
Rob Hamrick
Full Member
*
Offline



Posts: 11
Oakland/Berkeley, CA
Re: Query - Match All Except the Set  Regex ^
Reply #6 - 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.

Back to top
 
 
  IP Logged
Pages: 1
Send Topic Print