[英]Regex Version of Strip() - Automate the Boring Stuff with Python
[英]Regex for Phone Numbers in Automate the boring stuff with python
這段代碼是什么意思? (\d{3}|\(\d{3}\))
? 我了解 (\d{3}) 表示該數字重復 3 次,但我不了解它的 rest。 有人可以解釋一下嗎
"(\d{3}|\(\d{3}\))"
多么capturing
的正則表達式啊?
讓我們一一進行。
\d{3}
表示“匹配任何出現三次的數字”。
\( or \)
表示“匹配文字括號,但這根本沒有特殊含義”。
|
意思是“匹配上一條語句或下一條語句”。
( with )
表示“匹配我內心的正則表達式並捕獲/記住它們。”
匹配括號內的 3 位數字或 3 位數字並捕獲/記住匹配項。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.