Filter out filenames containing six digits

Tips on writing regular expressions for searching the post list

Moderators: Quade, dexter

Filter out filenames containing six digits

Postby randyripoff » Sat Mar 15, 2003 12:18 pm

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?
randyripoff
n00b
n00b
 
Posts: 9
Joined: Mon Jan 27, 2003 1:33 pm

Re: Filter out filenames containing six digits

Postby jimmy316 » Sat Mar 15, 2003 6:13 pm

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
User avatar
jimmy316
Seasoned User
Seasoned User
 
Posts: 514
Joined: Thu Dec 26, 2002 7:26 pm

Registered Newsbin User since: 04/12/03

Postby kewakl » Sat Mar 15, 2003 6:23 pm

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" <me@home.nut>
)

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?
User avatar
kewakl
Seasoned User
Seasoned User
 
Posts: 855
Joined: Sat May 26, 2001 7:26 pm
Location: Way Out There - Even farther now!

Registered Newsbin User since: 04/01/03

Postby randyripoff » Sat Mar 15, 2003 7:28 pm

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.
randyripoff
n00b
n00b
 
Posts: 9
Joined: Mon Jan 27, 2003 1:33 pm

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

Postby cdtoaster » Sat Apr 19, 2003 12:16 am

/[0-9]{6}/ would do it in Perl. Haven't tested it out in NB yet, having too much fun looking for EBOOKS :wink:
cdtoaster
n00b
n00b
 
Posts: 2
Joined: Fri Apr 18, 2003 11:18 pm

Registered Newsbin User since: 05/12/03

Postby dexter » Sat Apr 19, 2003 4:43 am

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.
User avatar
dexter
Site Admin
Site Admin
 
Posts: 9514
Joined: Fri May 18, 2001 3:50 pm
Location: Northern Virginia, US

Registered Newsbin User since: 10/24/97

Postby kewakl » Sat Apr 19, 2003 9:38 pm

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> ??
User avatar
kewakl
Seasoned User
Seasoned User
 
Posts: 855
Joined: Sat May 26, 2001 7:26 pm
Location: Way Out There - Even farther now!

Registered Newsbin User since: 04/01/03

Postby sqlboy » Tue May 06, 2003 8:41 pm

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.
User avatar
sqlboy
Site Admin
Site Admin
 
Posts: 87
Joined: Sat Mar 01, 2003 10:14 pm

Registered Newsbin User since: 05/08/03

Postby dexter » Tue May 06, 2003 11:32 pm

Nope
User avatar
dexter
Site Admin
Site Admin
 
Posts: 9514
Joined: Fri May 18, 2001 3:50 pm
Location: Northern Virginia, US

Registered Newsbin User since: 10/24/97

Postby georger » Wed Feb 16, 2005 12:37 am

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?
georger
n00b
n00b
 
Posts: 2
Joined: Wed Feb 16, 2005 12:20 am


Return to Regular Expressions

Who is online

Users browsing this forum: No registered users and 1 guest