我试图从文本中提取德国增值税编号(Umsatzsteuer IdentificationsNummer)
string = "I want to get this DE813992525 number."
我知道,这个问题的正确正则表达式是(?xi)^( (DE)?[0-9]{9}|)$
。
根据我的demo,它工作得很好
我尝试的是:
string = "I want to get this DE813992525 number.
match = re.compile(r'(?xi)^( (DE)?[0-9]{9}|)$')
print(match.findall(string))
>>>>>> []
我想得到的是:
print(match.findall(string))
>>>>> DE813992525
在字符串中搜索时,不要使用
^
和$
:输出:
相关问题 更多 >
编程相关推荐