Article View: news.software.readers
Article #243246Re: Dialog (regex defect): Action rule using "Header" scans into body of post
From: VanguardLH
Date: Tue, 16 Nov 2010 04:43
Date: Tue, 16 Nov 2010 04:43
78 lines
5440 bytes
5440 bytes
Well, that almost worked. If I include the "(?-m)" operator then I have to remove the trailing "$" anchor in the regex. For example, say the Path header has (it's been shortened here to show on one line just as it was in the post): Path: news.mynsp.net!host.othernsp.com!not-for-mail If the regex is: ^Path: .+![^!]+\.othernsp\.com(!not-for-mail)?$ then there is a match; however, as discovered, this match might span multiple lines which means I might be getting the last part of the string from a different header. So I added the "(?-m)" as follows: (?-m)^Path: .+![^!]+\.othernsp\.com(!not-for-mail)?$ So now the regex looks for a matching string on just one line. Yet I get no match. I have to remove the trailing "$" end-of-line anchor at the end of the regex. Well, yeah, I then get a match but now the regex is not guaranteeing that the string is at the *end* of the line. The problem is that the text being tested will very well have multiple lines (there are many lines for all the headers). If I paste in the Path header's value in one line (not even a following blank line) then there is a match. But there will be more than one line in the headers section. As soon as I add a block of headers to see if the regex works, there is no match. So it seems the (?-m) doesn't restrict the parsing to one line but requires the entire test string to be on only 1 line which won't happen with headers in posts. 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. If I don't use the "(?-m)" operator, there is a match but it can extend to multiple lines. This means the test string might not be in the header that you specified but contained in a following header's value. If I do use the "(?-m)" operator, there is no match despite that the test string is most definitely to be found in the one line for the Path header. 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).
Technical Details
Message-ID:
<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!goblin2!goblin.stu.neva.ru!weretis.net!feeder4.news.weretis.net!news.albasani.net!not-for-mailReferences:
<ibieuc$fa1$1@news.albasani.net> <4jnelelbf8ic.dlg@mid.crommatograph.info> <ibrutm$26h$1@news.albasani.net>Show Full Headers
Complete Article Headers
Message-ID: <ibt23d$lq6$1@news.albasani.net> Subject: Re: Dialog (regex defect): Action rule using "Header" scans into body of post Date: Mon, 15 Nov 2010 22:43:21 -0600 From: VanguardLH <V@nguard.LH> References: <ibieuc$fa1$1@news.albasani.net> <4jnelelbf8ic.dlg@mid.crommatograph.info> <ibrutm$26h$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!goblin2!goblin.stu.neva.ru!weretis.net!feeder4.news.weretis.net!news.albasani.net!not-for-mail Newsgroups: news.software.readers Organization: 0.35MOA sniper at loose in Usenet Lines: 78 Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: news.albasani.net Re2Gt1qX6Wx6vWRsMnXyFBI5u9qp42u9hwjo6dxuTD0zgcr0LOgpgbdEz/zOORONNgJBl6n7WsRiMYiuWkWoFD5q94R1llWi2JEbyED19LHEBOIoGfvBzaXJPfXjZPoX NNTP-Posting-Date: Tue, 16 Nov 2010 04:42:22 +0000 (UTC) Keywords: VanguardLH VLH811 Cancel-Lock: sha1:Wjx20TUcGK5EYiqi5uYHupNAbvU= User-Agent: 40tude_Dialog/2.0.15.41 Injection-Info: news.albasani.net; logging-data="VGeQgnAas+ino5bQIALgzOrdAc/9se+addtzhCPyjoWp91e8UtvzFRZoEAR3/kYchhgWCp+Js+Sy8DwIi6zOeRQjjr8g/CtkZWT9cT9vvKZiWfQRBSX+nZrNBGl+2IhA"; mail-complaints-to="abuse@albasani.net" X-MOTD: It is wiser to remain silent and let others ponder your ignorance than to speak and remove all doubt