language: Python 3 (python-3.2.3)
date: 1001 days 16 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
import re
 
def replace(match):
    if match.group(0)[0] == '/': return match.group(0)
    else: return '<' + match.group(0) + '>'
 
source = '''http://a.com http://b.com
//http://etc.'''
 
pattern = re.compile(r'(?m)^//.*$|http://\S+')
result = re.sub(pattern, replace, source)
print(result)