[英]Parentheses in regular expression pattern when splitting a string
我想知道以下行為的原因:
>>> re.compile("(b)").split("abc")[1]
'b'
>>> re.compile("b").split("abc")[1]
'c'
我似乎在拆分模式周圍加上括號時,將其重新添加到拆分數組中。 但為什么? 它是一致的東西,還是僅僅是正則表達式的孤立功能。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.