Article View: news.software.readers
Article #234839Re: The Regular Expressions in turbo-plonk.sl
From: ShadowTek
Date: Thu, 30 Jul 2009 05:28
Date: Thu, 30 Jul 2009 05:28
61 lines
3660 bytes
3660 bytes
On 2009-07-29, _@Jeff_Relf.Seattle.inValid <_@Jeff_Relf.Seattle.inValid> wrote:
> This is simple:
> “ variable hdr = "extract_article_header(\"From\")";
> [...]
> variable expression = "(string_match("+hdr+
> ",\"[^ ]+ +[^ ]+ +<.+@.+>\",1) == 0) and (string_match("+hdr+
> ",\"peter\\.bergt\",1) == 0) and (string_match("+hdr+
> ",\".+@.+ +([^ ]+ [^ ]+.+)\", 1) == 0)";
> do { if (eval(expression)) [...] ”.
> www.wannabeHacker.COM/src/turbo-plonk.sl
>
> “hdr” contains the “From:” line; it's just text, a string.
> “expression” contains:
> “ string_match( hdr, "[^ ]+ +[^ ]+ +<.+@.+>" , 1 ) == 0 and
> string_match( hdr, "peter\.bergt" , 1 ) == 0 and
> string_match( hdr, ".+@.+ +([^ ]+ [^ ]+.+)", 1 ) == 0
>
> For “ From: Nicholas <Lawrence_Glickman@comcast.net> ”,
> the Regular Expression "[^ ]+ +[^ ]+ +<.+@.+>" matchs:
>
> blackSpace (“From:”), whiteSpace, blackSpace (“Nicholas” ) and
> “<Lawrence_Glickman@comcast.net>”.
>
> ".+@.+ +([^ ]+ [^ ]+.+)" matchs:
> “ From: Lawrence_Glickman@comcast.net (Nicholas) ”.
lol It might be "simple" if you've done it a few times, but I'm still
trying to understand exactly how each part these regular expressions
work.
I've read
http://www.s-lang.org/doc/html/slang-22.html
but I stil don't understand everything that I'm seeing.
Take this second argument for example:
(string_match("+hdr+",\"[^ ]+ +[^ ]+ +<.+@.+>\",1) == 0)
The first characters are
\"
which escapes the double quote and allows it to become part of the
string that the first argument will be checked against, right?
Then this:
[^ ]
The doc states:
> [ ... ] matches any single character between brackets
> ^ matches beginning of a line.
So shouldn't this mean that
[^ ]
is trying to match if a single empty space exists at the beginning of a
line?
You said that
[^ ]
should match the blackspace "From:", but where is *this* functionallity
documented in slang?
I'm just trying to understand one thing at a time at this point.
Technical Details
Message-ID:
<slrnh72bf5.njk.ShadowTek@desktop.localdomain>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!border1.nntp.ams.giganews.com!nntp.giganews.com!feeder.erje.net!feeder.eternal-september.org!eternal-september.org!not-for-mailReferences:
<slrnh6sm2b.be4.ShadowTek@desktop.localdomain> <20090729080451@usenet.piggo.com> <slrnh6v215.m8d.ShadowTek@desktop.localdomain> <20090729101510@usenet.piggo.com> <slrnh6vnoo.8ce.ShadowTek@desktop.localdomain> <20090729175840@usenet.piggo.com> <_@Jeff_Relf.Seattle.2009_Jul29.6.16am.7d>Show Full Headers
Complete Article Headers
Message-ID: <slrnh72bf5.njk.ShadowTek@desktop.localdomain> Subject: Re: The Regular Expressions in turbo-plonk.sl Date: Thu, 30 Jul 2009 05:28:56 +0000 From: ShadowTek <ShadowTek@invalid.invalid> References: <slrnh6sm2b.be4.ShadowTek@desktop.localdomain> <20090729080451@usenet.piggo.com> <slrnh6v215.m8d.ShadowTek@desktop.localdomain> <20090729101510@usenet.piggo.com> <slrnh6vnoo.8ce.ShadowTek@desktop.localdomain> <20090729175840@usenet.piggo.com> <_@Jeff_Relf.Seattle.2009_Jul29.6.16am.7d> 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!border1.nntp.ams.giganews.com!nntp.giganews.com!feeder.erje.net!feeder.eternal-september.org!eternal-september.org!not-for-mail Newsgroups: news.software.readers Organization: A noiseless patient Spider Lines: 61 Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: news.eternal-september.org U2FsdGVkX1+FKPk2pmbx4J2mysQ8l/VYFPuRJOPXsEGyDZrBjdpLieiePDg0nXDcCr8BT3Uc8fPgsNbREMX9YcfjQlJzqb3Lfp4Ltj+pYsNlvFjUrD9P9GHR/Ly64N68R3ZdO/7AyJThASUjYdTIb7EpnR1U2N94 X-Complaints-To: abuse@eternal-september.org NNTP-Posting-Date: Thu, 30 Jul 2009 05:28:56 +0000 (UTC) X-Auth-Sender: U2FsdGVkX19wTYYw0Giu3LK/JjE3MKCmWWUtFXKAx9PZeCd+IVQkdQ== Cancel-Lock: sha1:xuwhJrLNH361aJwLwW6wdQWHpec= User-Agent: slrn/pre1.0.0-2 (Linux)