parsing - How to stick a wildcard in a string in Python? -


i want create simple chatbot type program. after experimenting aiml, , finding lacking, decided see if python has chance of working. want able take sentence like

"what color sky?"

and respond intelligible answer. so, want use wildcard symbols if/else statements in python. maybe this:

statement = input() if statement == "_ color _ sky":     print(sky_color) 

if know of library(hopefully built in:-]) has tool or little escape character type trick, appreciated.

regex matching seems want

>>> import re >>> re.search(".*color.*sky.*", "where i?") == none true >>> re.search(".*color.*sky.*", "what color sky") == none false >>> re.search(".*color.*sky.*", "what color rose") == none true 

it gives none if pattern not match.


Comments