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

Popular posts from this blog

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -

javascript - Using jquery append to add option values into a select element not working -

javascript - Restarting Supervisor and effect on FlaskSocketIO -