Re: find and replace, and other questions
Kurt Bigler <kkb-qsUyPSV3HvqUK90frp/[email protected]> Mon, 13 Dec 2010 23:49:30 -0800
| Newsgroups | gmane.mail.spam.crm114 |
|---|---|
| Message-ID | <C92C618A.2BB8E%[email protected]> |
On 12/13/10 6:26 AM, "[email protected]" <[email protected]> wrote: > Ahhh, it's been a long time, eh? Yea, and back again. Maybe not to be Blamed this time. We'll see. ;) > First off, the "\-constants" mentioned in the manual aren't the same as > the back reference \1, \2, etc. I was just hoping the writing had been sloppy--since a digit looks like a "constant". ;) > The \-constants are things like \n (newline), \t (tab) and \xHH (hex > char) and \oOOO (octal char) are constants in the "C" language sense. > They exist solely so that it's easy to put in a single byte wide > character of whatever value desired easily. > > But- the \1, \2, etc. values are REGEX-engine back-references. They > aren't constants; the regex engine is constantly rebinding them as it > tries to do the first-longest REGEX match. Thus, they are in a state of > flux until the regex completes. Further, the regex engine doesn't > explictly export them back; rather the parenthesized variables _are_ > exported back, explicitly, and Ville Laurikari (the author of TRE) is > very careful not to break that part of the interface.. > > Note also that \1, \2 etc. are _usually_ but not _always_ mapped to the > "bound variables" you get out of a match statement. That's because in > TRE (and thus in CRM114) it's possible to set a "no bind" on a > parenthesized subexpression (I'm trying to find that; I recall seeing it > but can't find it now). Just to be complete and clear, in spite of your following admonition, the value in ALTER's // is a "varexpanded string" which I think is none of TRE's business, right? > So- the bottom line is that it might be possible to do your \1 modifier, > but it would be fraught with peril, and not stable with respect to > Ville's work. > > Thus, I'd say "find a different problem to work on". :( However I think I already have my solution. I never cared about the syntax, I just wanted a solution. It couldn't be done with *no* changes to mailfilter, but the changes were less than I thought when I used the word "hack". I did it for non-line-spanners only. The prototype fix required changes to two lines: match [:m_text:] <nomultiline> (:place:) /:*:fr:/ BECOMES: match [:m_text:] <nomultiline> (:place: :_1: :_2:) /:*:fr:/ and alter (:place:) /:*:to:/ BECOMES: eval (:place:) /:*:to:/ And then I can freely use () groups on the "LHS" of >-> and :*:_1: etc. (as far as I care to support) on the "RHS". Not sure if using eval there has any gotchas, but trivial test cases work. Voila! And probably I can (and really should) make it more efficient by evaluating :to: only once outside the inner loop of the rewrite processing, but haven't tried yet. And a clean way to do it might be to provide something like >=> instead of >-> to support "RHS" evaluation and maybe :_1: thru :_9: . > re: the library: > > And yes, our major effort this year has been to create / improve the > C-callable library. For a lot of users (especially the user who's > paying for this work to be done!), the ability to integrate tightly (and > the speedup when you change from the CRM114 JIT language compiler to a > C-callable subroutine call) is really important. > > The library is LGPLed, and on the download page of the web site. Right > now I'm making an improved tenfold-validate program to test yet another > new classifier- a boosted RULAX (Are You Like An X) classifier. The > idea is to use boosting (an array of very simple but weak classifiers) > to build a strong classifier by voting. Sounds good! -Kurt ------------------------------------------------------------------------------ Lotusphere 2011 Register now for Lotusphere 2011 and learn how to connect the dots, take your collaborative environment to the next level, and enter the era of Social Business. http://p.sf.net/sfu/lotusphere-d2d _______________________________________________ Crm114-general mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/crm114-general