Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Grepping with Python - script/prog required.

Reply
Thread Tools

Grepping with Python - script/prog required.

 
 
John Fitzsimons
Guest
Posts: n/a
 
      06-24-2003

Hi,

I want to search an ordered text file and list web links such as :

Input like ;

A
Folder
Freeware
ftp://ftp.eunet.bg/pub/simtelnet
http://clients.net2000.com.au/~johnf/faq
Keywords:
Personal
Reach
Site
stuff
Toolbar
www.fourmilab.ch/annoyance-filter/

and Output like ;

ftp://ftp.eunet.bg/pub/simtelnet
http://clients.net2000.com.au/~johnf/faq
www.fourmilab.ch/annoyance-filter/

Can anyone suggest the code and/or a python program/script I could
adapt to do this please ?


Regards, John.

 
Reply With Quote
 
 
 
 
John Fitzsimons
Guest
Posts: n/a
 
      07-01-2003
On Mon, 23 Jun 2003 17:52:30 -0700, "Mike Rovner" <>
wrote:

>John Fitzsimons wrote:


Hi Mike,

>> I want to search an ordered text file and list web links such as :
>> and Output like ;


>> ftp://ftp.eunet.bg/pub/simtelnet
>> http://clients.net2000.com.au/~johnf/faq
>> www.fourmilab.ch/annoyance-filter/


>> Can anyone suggest the code and/or a python program/script I could
>> adapt to do this please ?


>That's very dirty (with high false positive and negative hits) url
>recognizer:


>import re
>url=re.compile(r'(?<=\s)(??:ftp|http|https)://|www(?:\.[^\. ]+){2,}).*?(?=
>\s)')
>print '\n'.join(re.findall(url, your_text_goes_here))


As I am a total newbie I will need to work out how to make that a
python file BUT as you have done the hard work it should be a lot
easier now.

It also looks like it might be close to being able to be used as a
regex string for something like NoteTab. Though, if using search and
replace, I would need to make it search for everything NOT matching
the above syntax and replace it with nothing.

I will also need to work out what "Closure cannot immediately follow
BegOfLine, EndOfLine or another closure" means, and fix it.

Many thanks for your help.


Regards, John.
..
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[ANN] Grepper 0.9.3: grepping library and commandline tool David A. Black Ruby 3 01-19-2009 07:13 PM
[ANN] Grepper: object-oriented grepping David A. Black Ruby 1 12-24-2008 02:17 AM
perl efficiency -- fastest grepping? Bryan Krone Perl Misc 5 11-16-2004 06:39 PM
perl efficiency -- fastest grepping? Bryan Krone Perl 1 11-08-2004 11:15 PM
grepping lines above and below a pattern found mike Perl Misc 15 05-21-2004 08:46 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57