如果用户输入数字的两个第一个数字与33匹配,我如何检查正则表达式?
答案 0 :(得分:1)
import re
pattern = "^33" # ^ means begin of the string
pattern = re.compile(pattern)
if pattern.search(YourUserInput):
# Your code
答案 1 :(得分:0)
import re
if re.match('^33', s):
print "String %s starts with 33..." % s