Article View: news.software.readers
Article #243244Re: Dialog (regex defect): Action rule using "Header" scans into body of post
From: Tom B.
Date: Tue, 16 Nov 2010 08:10
Date: Tue, 16 Nov 2010 08:10
68 lines
4256 bytes
4256 bytes
VanguardLH wrote in "news.software.readers" ... [trimmed] > I'll give an easy example. Open Dialog's regular expression tester. In > regex field, enter: > > (?-m)^Path: .+![^!]+\.othernsp\.com(!not-for-mail)?$ > > In the "match on" field, enter (as 3 lines): > > Organization: me and mine > Path: news.mynsp.net!news.othernsp.com!not-for-mail > X-Complaints: abuse@report.othernsp.com > > There is NO match. I've told the regex to NOT use mutli-line mode and > that the test string is at the end of the line. This is true but there > is no match. Now change "(?-m)" to "(?m)" (or just remove this prefix > operator since multi-line mode is the default mode), so you have: > > (?m)^Path: .+![^!]+\.othernsp\.com(!not-for-mail)?$ > or > ^Path: .+![^!]+\.othernsp\.com(!not-for-mail)?$ > > There is now a match but it is greedy and extends beyond the Path header > line to the end of the X-Complaints header line (i.e., the match is > across multiple header values). That's what I'm trying to avoid. It may be the dot(s). I don't know how Marcus compiled the PCREs. I assume Dialog was compiled with the PCRE_DOTALL option which means the dot also matches newlines. In this case the ".+" means keep searching, even across newlines, until the next stuff matches or it fails at the end of the article. You could try keeping multi line but unsetting DOTALL (or set it depending on the compiled option). (?-s) unsets DOTALL, and of course (?s) sets it (probably default) [snip] > The test string must be at the end of the header's value. For now, I'll > settle for testing for the string at end of the SAME line as where the > header is identified. The parsing must not extend beyond one line to > possibly find the test string in another line for a different header. > To make sure the string is at the end of the line, it appears that I > need to use the "$" anchor. Yet this does NOT dictate that the > end-of-line character be in the same line as the header's title. The > test string could be at the end of a subsequent line for a completely > different header. The "(?-m)" operator only works if the entire test > text is comprised of a single line (and apparently which is not > terminated with \n) which will never be true for the headers section in > newsgroup posts. > > So I'm still looking for a viable regex to look for the specified string > ONLY within the header that is identified, and possibly with that string > at the end of the line (for THAT specified header's value). $ also has compiler options but I don't think there is an option for the user. So in multi line mode you are probably stuck with $ at end of subject - the whole article in multi line mode. Using "\r\n" instead of "$" may work (seems to work with Gravity's PCREs). Or some other hack like "[^\w ]" (include the space). I don't really know, I only tested them once. -- Tom B. * * * Gravity Web Pages * * * http://mpgravity.sourceforge.net/ (official site) http://gravity.tbates.org/
Technical Details
Message-ID:
<MPG.274c0684271c22009896b2@news.individual.net>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!num2.nntp.dca.giganews.com!num1.nntp.dca.giganews.com!number.nntp.dca.giganews.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!postnews.google.com!news4.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mailReferences:
<ibieuc$fa1$1@news.albasani.net> <4jnelelbf8ic.dlg@mid.crommatograph.info> <ibrutm$26h$1@news.albasani.net> <ibt23d$lq6$1@news.albasani.net>Show Full Headers
Complete Article Headers
Message-ID: <MPG.274c0684271c22009896b2@news.individual.net> Subject: Re: Dialog (regex defect): Action rule using "Header" scans into body of post Date: Tue, 16 Nov 2010 03:10:34 -0500 From: "Tom B." <nfn03862@naples.net> References: <ibieuc$fa1$1@news.albasani.net> <4jnelelbf8ic.dlg@mid.crommatograph.info> <ibrutm$26h$1@news.albasani.net> <ibt23d$lq6$1@news.albasani.net> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!num2.nntp.dca.giganews.com!num1.nntp.dca.giganews.com!number.nntp.dca.giganews.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!postnews.google.com!news4.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Newsgroups: news.software.readers Lines: 68 Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: individual.net KMW4UkeBpZt7IxEkhROMtAjDi3rovmRXcLPCnr6Hd3kgWz2rg= Cancel-Lock: sha1:YjybV3UU8+WnNrvlrtxyeqPLUXo= User-Agent: MicroPlanet-Gravity/3.0.4