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

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

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -