我想知道如何找到slach和括號或']之間的字符串,例如。從斜槓查找字符串到空格或字符
data = "(AVP:SMTP/[email protected]) R:AVP:SMS.0/+44648474 id:24"
data2 = "(AVP:SMTP/<[email protected]>) R:AVP:FAX.0/<thisword> id:25"
SI的想法是隻得到[email protected]
和+44648474
用於爲data2
第一data
和[email protected]
和thisword
我試過這個表達式:
k = re.findall(r"/(\S+)",data2)
但它返回<[email protected]>)
和<thisword>
和我想得是[email protected]和thisword
如果你輸入的子字符是'/ <[email protected]>)',並且你想要斜槓和括號之間的所有內容,顯然這將包括'<' and '>';如果你想排除這些,你需要在正則表達式中這樣做。 – 2013-04-29 13:00:07