OT: PERL Question

OT: PERL Question

How do I search for a range of multi-digit numbers, say find any three digit number between 192 and 222? ...Jim Thompson

-- | James E.Thompson | mens | | Analog Innovations | et | | Analog/Mixed-Signal ASIC's and Discrete Systems | manus | | San Tan Valley, AZ 85142 Skype: skypeanalog | | | Voice:(480)460-2350 Fax: Available upon request | Brass Rat | | E-mail Icon at

formatting link
| 1962 | I love to cook with wine. Sometimes I even put it in the food.

Reply to
Jim Thompson
Loading thread data ...

2nd reply, since GigaNews doesn't seem to like alt.binaries.

Note that I do all my Perl programming with

formatting link
open. I'm mostly not a Perl programmer!

I know you can search for groups of three digits, and probably groups of three digits bound by non-digits (I'm pretty sure you can search on "\D(\d \d\d)\D", but I know that "[^0-9]([0-9][0-9][0-9])[^0-9]" will work -- there's probably a way to say "repeat three times" but I don't know it).

I'd identify groups of three, then parse them for value and test with an if statement. I'm pretty sure that making regular expressions to test by value in the text would be exceptionally tedious.

--

Tim Wescott 
Wescott Design Services 
http://www.wescottdesign.com
Reply to
Tim Wescott

formatting link
(don't forget the mouseover text)

Independent of language, I'm guessing the best answer will be regular expressions. Most all languages support regex. Sadly I don't know them, so I can't compose one offhand.

Hmm, just asked a friend, says a regex would be obscene. Nevermind.

For a heavy weight solution, I wonder if it could be fed into Google Docs and queried with Google search tools? That supports a range search.

Tim

-- Seven Transistor Labs, LLC Electrical Engineering Consultation and Contract Design Website:

formatting link

"Jim Thompson" wrote in message news: snipped-for-privacy@4ax.com...

Reply to
Tim Williams

Assuming between is inclusive, this, I think:

\D(19[2-9]|2[01][0-9]|22[012])\D

--
umop apisdn
Reply to
Jasen Betts

Put your numbers in a hash and test against the hash.

#!/usr/bin/perl

use strict; my %numbers;

foreach my $i ( 110 .. 256 ) { $numbers{$i} = 1; }

while () { chomp;

my $n = $_; print "$n matches\n" if ( $numbers{$n} ); print "$n does not matches\n" if !( $numbers{$n} );

} __DATA__

193 199 23 254
Reply to
Owen Cook

[snip]

Why make life so complicated, this works...

(\[192\.119\.(14[4-9])|(15[0-9])\.)

In case you haven't guessed, when I get spam, I look up the originator with NetScanTools and killfile his whole netrange... in Eudora it's called double-trash... I never see them at all ;-) ...Jim Thompson

--
| James E.Thompson                                 |    mens     | 
| Analog Innovations                               |     et      | 
| Analog/Mixed-Signal ASIC's and Discrete Systems  |    manus    | 
| San Tan Valley, AZ 85142     Skype: skypeanalog  |             | 
| Voice:(480)460-2350  Fax: Available upon request |  Brass Rat  | 
| E-mail Icon at http://www.analog-innovations.com |    1962     | 
              
I love to cook with wine.     Sometimes I even put it in the food.
Reply to
Jim Thompson
[snip]

Interesting discovery as I stop all spam... RHSBL seems to stop most international spam, but US spam seems to "keep on ticking" irrespective of abuse complaints.

So I've been tracking down the URL address ranges of spammers... most comes from a single company in Nevada: ENZUINC-US-BLKxx

Just killfile all their block addresses (*) in Eudora... double-trash... and never seen _at_all_ >:-}

(*) Like:

(\[192\.119\.(14[4-9])|(15[0-9])\.)|(\[195\.230\.31\.)|(\[23\.24[4-5]\.)|(\[45\.62\.(16[0-9])|(17[0-9])|(18[0-9])|(19[0-1])\.)|(\[107\.183\.)

The quiet is deafening ;-) ...Jim Thompson

--
| James E.Thompson                                 |    mens     | 
| Analog Innovations                               |     et      | 
| Analog/Mixed-Signal ASIC's and Discrete Systems  |    manus    | 
| San Tan Valley, AZ 85142     Skype: skypeanalog  |             | 
| Voice:(480)460-2350  Fax: Available upon request |  Brass Rat  | 
| E-mail Icon at http://www.analog-innovations.com |    1962     | 
              
I love to cook with wine.     Sometimes I even put it in the food.
Reply to
Jim Thompson

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.