1
我想獲得像「[email protected]」的輸出,但它只顯示「com」作爲匹配的表達式。如何使用findall獲得完整的匹配表達式?findall模塊重新在python
>>> pat = re.compile('[a-zA-Z0-9][\w\.]{4}[\w\.]*@[a-zA-Z0-9][a-zA-Z0-9]*[.](com|co.in|org|edu)')
>>> pat.findall('[email protected]')
['com']
>>> pat.findall('[email protected] [email protected]')
['com', 'org']
Required Output:-
['[email protected]']
['[email protected]', '[email protected]']
是不是要逃避「co.in」中的點也是必要的? – Dropout
@Dropout正確地指出,謝謝:) – Jerry
+1現在;)乾杯! – Dropout