Grepping with Python - script/prog required.

Discussion in 'Python' started by John Fitzsimons, Jun 24, 2003.

  1. John Fitzsimons, Jun 24, 2003
    #1
    1. Advertising

  2. 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.
    ..
     
    John Fitzsimons, Jul 1, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bryan Krone

    perl efficiency -- fastest grepping?

    Bryan Krone, Nov 5, 2004, in forum: Perl
    Replies:
    1
    Views:
    1,508
    Jim Gibson
    Nov 8, 2004
  2. -intl.com
    Replies:
    1
    Views:
    382
    Martin Gregorie
    Oct 22, 2006
  3. David A. Black

    [ANN] Grepper: object-oriented grepping

    David A. Black, Dec 24, 2008, in forum: Ruby
    Replies:
    1
    Views:
    158
    Tiago Nogueira
    Dec 24, 2008
  4. David A. Black
    Replies:
    3
    Views:
    135
    Florian Gilcher
    Jan 19, 2009
  5. mike
    Replies:
    15
    Views:
    230
    Anno Siegel
    May 21, 2004
Loading...

Share This Page