Created
July 2, 2012 18:56
-
-
Save luztak/3034918 to your computer and use it in GitHub Desktop.
RegEx for [at] and urls.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
at_user_filter = re.compile(r'(?:^|\W)@(\w+)') | |
email_filter = re.compile('(\w{1,63})@([A-Za-z0-9\.\-] ).(com|net|org|me|in|fm|co|biz|info|mobi|cc)') | |
#you can add suffixes by asking Google for domain suffix information. | |
url_filter = re.compile(u'((http(s|)|ftp)://|)(\w{0,}\.|)(\w{1,63}).(\w{2,4})((/((.*)|)|))') |
擦,?:这个我还真解释不上来,爪机无力自行百度吧...
mail你歧视了一大片非主流后缀,url我看那re写的太蛋疼就没看...这括号跟lisp似的...
@whtsky - -||那邮箱的domain suffix直接跟url一样处理吧……至于url,我用?代替|)试试.
@whtsky url实在晕……先不管了.
@whtsky ?:明白了……
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@whtsky mail/url有问题么?怎么感觉有了url完全可以不要md的inline link了.