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

Den fredag den 12. juni 2015 kl. 01.18.17 UTC+2 skrev Tim Williams:

I'm no expert on regex, but I think this works

19[2-9]|2[0-1][0-9]|22[0-2]

-Lasse

Reply to
Lasse Langwadt Christensen

Thanks for the nudge, Lasse. I think something like that will work. ...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

Tested, it does work, Thanks! ...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

It's just a regex thing- first hit on Google

formatting link

--
Best regards,  
Spehro Pefhany 
Amazon link for AoE 3rd Edition:            http://tinyurl.com/ntrpwu8 
Microchip link for 2015 Masters in Phoenix: http://tinyurl.com/l7g2k48
Reply to
Spehro Pefhany

Assuming between is inclusive, this, I think:

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

--
umop apisdn
Reply to
Jasen Betts

a digit is denoted by \d, so \D(\d{3})\D ; checking that by running in Perl debugger

perl -de 1

main::(-e:1): 1 DB $_= "abc123def"

DB ($a)=/\D(\d{3})\D/

DB p $a

123

So then you'd check if this 3-digit number is in the range

p (192 < $a ) && ($a < 222)

Reply to
Przemek Klosowski

Lasse's suggestion helped me sort it out, but your post reminded me that I have a copy of "Regex Buddy" which does exactly what your link does... I just need to install it on this machine. ...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.