[英]Regex for Phone Numbers in Automate the boring stuff with python
what does this code mean?这段代码是什么意思?
(\d{3}|\(\d{3}\))
? (\d{3}|\(\d{3}\))
? I understand that (\d{3}) means that the digit is repeated 3 times, but I don't understand the rest of it.我了解 (\d{3}) 表示该数字重复 3 次,但我不了解它的 rest。 Can someone please explain
有人可以解释一下吗
"(\d{3}|\(\d{3}\))"
What an eye- capturing
regex hm?多么
capturing
的正则表达式啊?
Let's do this one by one.让我们一一进行。
\d{3}
means "match any number that occurs three times." \d{3}
表示“匹配任何出现三次的数字”。
\( or \)
means "match the literal parenthesis, but this has no special meaning at all." \( or \)
表示“匹配文字括号,但这根本没有特殊含义”。
|
means "match the previous statement OR the next statement."意思是“匹配上一条语句或下一条语句”。
( with )
means "match the regex inside me and capture/remember them." ( with )
表示“匹配我内心的正则表达式并捕获/记住它们。”
Match a 3-digit number or a 3-digit number inside parentheses and capture/remeber the match.匹配括号内的 3 位数字或 3 位数字并捕获/记住匹配项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.