![](/img/trans.png)
[英]Re in python to find a word in a string starting with a character? [on hold]
[英]python re string starting with
在以下字符串中,如何表示该行以数字开头或以数字或多个结尾
line="He is a German called Mayer12345"
re.compile(r".*\d+\w$")
line="12He is a German called Mayer"
re.compile(r"^\d+\w .*")
只需使用 pipe,它是一个或用于正则表达式:
re.compile(r"(^\d+\w .*)|(.*\d+\w$)")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.