Regular Expression Hell?

Ben Park benpark at my-deja.com
Tue May 9 03:17:11 CEST 2000


I believe the spaces in 'ftp | http' should not be there.

this line
URL = re.compile(r'((ftp | http)://[\w-]+(?:\.[\w-]+)*(?:/[\w-]*)*)')
should be
URL = re.compile(r'((ftp|http)://[\w-]+(?:\.[\w-]+)*(?:/[\w-]*)*)')

A good place to learn RE is
http://www.python.org/doc/howto/regex/regex.html

Ben Park

In article <8f7d9n$ii7 at autodesk.autodesk.com>,
  "Akira Kiyomiya" <akira.kiyomiya at autodesk.com> wrote:
> Okay, these two regular expression codes are from Python Essential
Reference
> book and I am pretty confused about these.
>
> Could someone dare to explan step by step?
>
> e_mail = re.compile(r'([a-zA-Z][\w-]*@[\w-]+(?:\.[w-]+)*)')
>
> # I know [a-zA-Z] any lower or upper word.....[\w-]??  any
alphabetical
> character??  what is "-" after "\w"?
> # I know @, you need it for the e-mail....   Then, I am lost....
>
> URL = re.compile(r'((ftp | http)://[\w-]+(?:\.[\w-]+)*(?:/[\w-]*)*)')
>
> # I know ftp or http part plus "://" you need it for URL.  Then,.....
I am
> lost....
>
> Akira
>
>


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list