Page 1 of 1

Filter out filenames containing six digits

PostPosted: Sat Mar 15, 2003 12:18 pm
by randyripoff
I'm looking for a way to block filenames that are exactly six digits long. Is there a way to do this using regular expressions?

Re: Filter out filenames containing six digits

PostPosted: Sat Mar 15, 2003 6:13 pm
by jimmy316
randyripoff wrote:I'm looking for a way to block filenames that are exactly six digits long. Is there a way to do this using regular expressions?


Don't remember how but this can be done. Use your favorite search engine for a regular expression tutorial. If you have Agent, there is a regular expression help section

Jim

PostPosted: Sat Mar 15, 2003 6:23 pm
by kewakl
I think that
      ([^0-9]*[0-9][0-9][0-9][0-9][0-9][0-9][^0-9]*)
should do it.
It may miss some. Especially at the beginning and end of a line, so test it carefully. It may require more.
(
I've edited it now! It should be better than originally posted.
([0-9][0-9][0-9][0-9][0-9][0-9]
([^0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9]))
)
( I used
"TEST123456TEST.txt" "123456TEST123456.txt" "TEST123456.txt" "123456.txt"
as attachments. Newsbin filtered them and gave this message:
123456test<1 KB [01],Profile - Filename Filtered,3/15/2003 07:05,"me@home" <[email protected]>
)

The newsbin site has some regex help at: http://www.newsbin.com/nb33help/regexp.htm
Dexter mentions it in http://forums.newsbin.com/viewtopic.php?t=4322
but the (sentence-ending) period gets included in the link, so the link doesn't work! :? :?


Someone may have a compressed expression that will do the same thing,
but will others (or the newsbin REGEX engine) understand it?

([^0-9]*[0-9][0-9][0-9][0-9][0-9][0-9][^0-9]*)
Explained
(                       - Start Grouping filter expression
[^0-9]*             - Include ZERO or more leading Non-numeric character(s)
[0-9] ... [0-9]     - Check for 6 digits
[^0-9]*             - Include ZERO or more trailing Non-numeric character(s)
)                       - End Grouping filter expression


As used inside a set, the '^' operator EXCLUDES the set from the filter.
The '*' operator matches ZERO or more of the PRECEDING character(s) or set.


hth

PS...Just curious... Why six-digit filenames? EXACTLY and ONLY six-digits?
or just have six-digit strings IN them?

PostPosted: Sat Mar 15, 2003 7:28 pm
by randyripoff
I primarily download photos from the newsgroups, and there's a very aggressive spammer using an anonymous remailer to post lots of pics--all of which consist of filenames of six digits. Worse, said poster posts pics of naked children, which I do not need on my computer's hard drive. So I want to do everything I can to block this idiot, short of not downloading any pics from the groups.

I'll test out these expressions and let you all know if they work. Thanks.

Match 6 Digits /[0-9]{6}/

PostPosted: Sat Apr 19, 2003 12:16 am
by cdtoaster
/[0-9]{6}/ would do it in Perl. Haven't tested it out in NB yet, having too much fun looking for EBOOKS :wink:

PostPosted: Sat Apr 19, 2003 4:43 am
by dexter
No, NewsBin doesn't support all the nice perl RE things. I wish it would do \d \w etc, but it doesn't. Maybe I can talk Quade into plugging in a better RE parser. Unfortunately, a very small percentage of users make use of this so I doubt he'll spend much time on it.

PostPosted: Sat Apr 19, 2003 9:38 pm
by kewakl
a very small percentage of users make use of this


I *almost* only use it in the Find bar.

I put the homer gif back.
I used the COP gif just because I had it and it fit so well in the POLICE thread.
Didn't stop the silliness, but, what can? <SNIP> <SNIP> ??

PostPosted: Tue May 06, 2003 8:41 pm
by sqlboy
So right now you can't do [0-9]{6} for 6 numbers?

?

dexter wrote:No, NewsBin doesn't support all the nice perl RE things. I wish it would do \d \w etc, but it doesn't. Maybe I can talk Quade into plugging in a better RE parser. Unfortunately, a very small percentage of users make use of this so I doubt he'll spend much time on it.

PostPosted: Tue May 06, 2003 11:32 pm
by dexter
Nope

PostPosted: Wed Feb 16, 2005 12:37 am
by georger
If you wanted to enforce a length of input, could you could do something like this:

^[0-9]{6,12}$

for any didit 6 to 12 chars long? or {6} for only 6?