python通配符 任意一段字符_Python:正则表达式中带有通配符的字符串(Python: regex a string with a wildcard in it)...

What I would like to do is to allow the user to input something such as: "Torsion ? Group", wildcard and all (the wildcard being a whole word) and a true or false returned depending on whether found or not. So would I have something such as \b*\b? The Python manual says that \bfoo\b will match strings of the form "something foo something else" as well as "foo.". the issue that I am having is that I am even trying to start simple modifying another example I found:

inputstring = 'What is a Torsion Abelian Group (TAB)?'

str1 = "Abelian"

output = re.search("Torsion" + \bstr1\b + "Group", inputstring)

print output

I however get the output:

output = re.search("Torsion" + \bstr1\b + "Group", inputstring)

^

SyntaxError: unexpected character after line continuation character

Thus I am having difficulties finding a known string, let alone a wildcard. Any thoughts on either would be extremely appreciated.

Thanks,

Brian

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值