🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #160477

Re: [slrn] Need help with score regexp

#160477
From: W. Citoan
Date: Sat, 08 Jan 2005 17:29
82 lines
4362 bytes
DC wrote:
>  I am trying to devise a regular expression that will match x or more
>  consecutive occurrences of any character, except digits.

Is there any reason to exclude digits?  I guess in binary groups it
would be an issue, but in other groups it doesn't seem that it would
save many valid posts.  That exclusion makes it more complicated...

The following should match 4 or more of any character...

  Subject: \(.\)$1$1$1
  
I tested it with only 2 occurrences and it caught the double "e" in this
thread's subject line.

But if you want to exclude digits here are some ideas:

>  - 4 or more of *any* letter

  Subject: \([a-z]\)$1$1$1

This I also tested on using two characters (i.e. I only used one $1 in
testing).  I wasn't able to find posts that contained 4 repeats.

>  - 4 or more special chars like ~!@#$%^&*()-_=+[]{}|\/;:'"`<>,.?

If you want repeating characters than:

  Subject: \([-~!@#$%^&*()-_=+\[\]{}|\\/;:'"`<>,.?]\)$1$1$1

If you want to match any multiple occurrence of these characters and not
just a repeating pattern (i.e. "$%^#" in addition to "####"), then the
following:

  Subject: [-~!@#$%^&*()-_=+\[\]{}|\\/;:'"`<>,.?][-~!@#$%^&*()-_=+\[\]{}|\\/;:'"`<>,.?][-~!@#$%^&*()-_=+\[\]{}|\\/;:'"`<>,.?][-~!@#$%^&*()-_=+\[\]{}|\\/;:'"`<>,.?]

Now, I doubt these two will work directly as printed.  Without a test
post, I was unable to check the proper escaping.  Since some of those
characters have special meanings, they usually need to be escaped, but
not always when its inside [].  I based it off my memory of standard
regex (but I probably made some mistakes) and I'm not sure slang is
fully the same anyway.

You might want to build this one up as you go.  Start with a simple one
(like [-@#:;,.]) and add additional characters as you encounter them.
If simply adding the character doesn't work then escape it with a "\"
(like [-@#:;,.\[\]] where the brackets inside are escaped to prevent
them ending the outer brackets).  The "-" must be the first character
inside the brackets or it will be interpreted as a range and not a "-".

Normal regex has a "not" operator for ranges that makes defining this
case much, much easier, but I couldn't find a reference to it in slang.

>  I wish to allow digits, however, but not in this particular instance:
>  
>  Subject: HELP!!!!!!1!111!1!!!!!!!111!!!111111!!!!!

The following will match 1 or more numbers, followed by one or more !,
followed by one or more numbers.

  Subject: [0-9]+!+[0-9]

If you want to match any punctuation character, substitute the ! with
the [] expression from the previous rules.

>  PS:  A link to an excellent online reference/tutorial for writing s-lang
>  regexps would be very welcome, also.

I haven't found an excellent one.  paf the dog already posted the only
slang regex documentation I've seen.  There are some excellent tutorials
for "standard" regex.  You could try reading those and only focus on the
parts that slang actually implements.  A google search on regex should
pull up plenty.

If you want to point us to specific threads that you're having trouble
with, I'm willing to try helping...

- W. Citoan
-- 
Remember that no man loses other life than that which he lives, or lives
any other life than that which he loses.
-- Marcus Aurelius
Technical Details
Message-ID: <slrncu063p.3bg.wcitoan@wcitoan-via.supernews.com>
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!number1.nntp.ams.giganews.com!number1.nntp.dca.giganews.com!internal1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!cyclone-sf.pbi.net!216.218.192.242!news.he.net!news-hog.berkeley.edu!ucberkeley!newsfeed.stanford.edu!sn-xit-03!sn-xit-09!sn-xit-08!sn-post-02!sn-post-01!supernews.com!corp.supernews.com!not-for-mail
References: <slrnctrh9i.hsh.dcmoose@moosemeat.ca.INVALID>

Show Full Headers
Complete Article Headers
Message-ID: <slrncu063p.3bg.wcitoan@wcitoan-via.supernews.com>
Subject: Re: [slrn] Need help with score regexp
Date: Sat, 08 Jan 2005 17:29:34 -0000
From: "W. Citoan" <wcitoan@NOSPAM-yahoo.com>
References: <slrnctrh9i.hsh.dcmoose@moosemeat.ca.INVALID>
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!number1.nntp.ams.giganews.com!number1.nntp.dca.giganews.com!internal1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!cyclone-sf.pbi.net!216.218.192.242!news.he.net!news-hog.berkeley.edu!ucberkeley!newsfeed.stanford.edu!sn-xit-03!sn-xit-09!sn-xit-08!sn-post-02!sn-post-01!supernews.com!corp.supernews.com!not-for-mail
Newsgroups: news.software.readers
Organization: Posted via Supernews, http://www.supernews.com
User-Agent: slrn/0.9.7.4 (Win32)
X-Complaints-To: abuse@supernews.com
Lines: 82