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
Regular Expressions and Agents in 4.6 (Read 3497 times)
Pete Becker
Full Member
*
Offline



Posts: 23

Regular Expressions and Agents in 4.6
Mar 05th, 2009, 9:09am
 
I have a document that organizes various reports with names like "UK 7", i.e. a two-letter country code followed by a space followed by a number. I also have two attributes: NB is supposed to hold the country code, and Number holds the number. Originally (i.e. before 4.6) I used an agent to set those two attributes from the title. Essentially, the agent's query was Title((\w\w)\s+(\d+)), and the action was NB=$1;Number=$2. With 4.6 this stopped working: the regular expression doesn't match any note names. Title(.*) matches notes, but if I try to use anything more sophisticated, nothing matches. What do I need to do?
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Regular Expressions and Agents in 4.6
Reply #1 - Mar 5th, 2009, 9:56am
 
Odd, I tested Title((\w\w)\s+(\d+)) in v4.5.3 and it fails - as I'd expected as we use Name() and not Title() to search the notes name.  It may be that way back TB supported Title as an alternate for Name() though I was never aware of that. So you need:

Query:   Name((\w\w)\s+(\d+))
Action:   $NB=$1;$Number=$2

In v4.6+ we now prefix all references to attribute names on both sides of the operator with a '$'. TB will support legacy forms at present, but learn to change now as such support is likely to fall away over time. We also always quote literal test values being applied to string attributes.

Using the $ prefix in queries is a little more complex confusing. As, in v4.6, queries are now expressions, we should (may!) prefix all attribute names except when pattern matching like above; i.e. attribute(pattern string). So, this works:

Query:  Name((\w\w)\s+(\d+)) & $Name="todo"

This won't work:

Query:  $Name((\w\w)\s+(\d+)) & $Name="todo"  First $ is wrong


Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Pete Becker
Full Member
*
Offline



Posts: 23

Re: Regular Expressions and Agents in 4.6
Reply #2 - Mar 5th, 2009, 12:46pm
 
I tried a bunch of combinations last night, and didn't go back and look at them when I posted my message. So I probably had Name and not Title in the original. Sorry if I confused things.

In any event, Name((\w\w)\s+(\d+)) works now. I could have sworn I tried it last night without success! <g>

Thanks.
Back to top
 
 
  IP Logged
Pages: 1
Send Topic Print