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
Deleting text from a note using Agent (Read 5836 times)
Gordon Ferrier
Full Member
*
Offline



Posts: 6

Deleting text from a note using Agent
Apr 19th, 2008, 2:11am
 
I have a few hundred notes, each containing a quotation. Most of the quotations end with the same string of characters: a space followed by a "~" (tilde) then the name of the person who originated the quotation. These were imported from a single Word document into individual notes. I have created an Agent to extract the name of the author of the quote into an Author attribute, which worked successfully. I now want to delete this redundant text from the end of the note i.e. delete from the space character preceding the tilde through to the end of the note. I can capture this text using Agent logic in a regexp and backreferencing, thus:

Text(( ~.+))

This places the offending text into $1. What I then thought would be straightforward to do is Text=$Text-$1: however when I do that I end up with the redundant text appended to the end of the note, and that, of course, repeats each time the Agent runs.

I'm clearly doing something wrong, but what?

Back to top
 
 
  IP Logged
DerikBadman
Ex Member




Re: Deleting text from a note using Agent
Reply #1 - Apr 19th, 2008, 9:01am
 
Perhaps you'd want to capture the text you want to keep and then replace the Text attribute with that instead of capturing the text you don't want and trying to delete it. Make sense?
Back to top
 
« Last Edit: Apr 19th, 2008, 9:01am by DerikBadman »  
  IP Logged
Gordon Ferrier
Full Member
*
Offline



Posts: 6

Re: Deleting text from a note using Agent
Reply #2 - Apr 20th, 2008, 4:09am
 
DerikBadman's suggestion is an interesting example of thinking laterally, and certainly worth trying - thanks. I'd still like to know why my proposed "solution" doesn't work, however, if anyone can suggest a reason.
Back to top
 
 
  IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: Deleting text from a note using Agent
Reply #3 - Apr 21st, 2008, 1:02pm
 
Gordon Ferrier's proposed action

    Text=$Text-$1

doesn't work, because substraction isn't defined for strings.  Addition is defined, as concatenation: "cats"+"!" is "cats!".  But substraction is not defined.

Historically, the '+' operator for concatenation is used in quite a few popular computer languages; C++, Smalltalk, awk, and perl all share this, if I remember right.  

I've never seen '-' as "substring deletion", but I see no objection to it.  If the substring to be deleted occurs more than once, which occurence(s) should be deleted?
Back to top
 
 
WWW   IP Logged
Gordon Ferrier
Full Member
*
Offline



Posts: 6

Re: Deleting text from a note using Agent
Reply #4 - Apr 26th, 2008, 3:29am
 
Mark B pointed out that "-" is not supported as a string deletion operator, which certainly explains why my proposed "solution" didn't work. In fact I followed DB's suggestion and found the text I wanted to keep, and then replaced the whole of the note text with that. Intuitively, however, I think there may be occasions where deletion is the only option, although Mark's question about what to do when there is more than one occurrence of the search string is a good one. Logically the regexp ought to find the first (and probably longest) string that matches search string and that could be marked using back referencing. But then would the regexp engine stop at that point or continue trying to find more matches?
Back to top
 
 
  IP Logged
Pages: 1
Send Topic Print