Grepping with Python - script/prog required.

J

John Fitzsimons

J

John Fitzsimons

John Fitzsimons wrote:

Hi Mike,
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.
..
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top