I am using sqlalchemy version 0.7.8. I have come across an issue where my user can search a text in plain english but record in db can have special characters between text. So if user enters "please come early to the hospital" and in db i have "please, come early, to the hospital." then my query must return exactly please, come early, to the hospital.
i have found this easy solution.
needle = func.replace(func.replace(Message.text, ',', ''), '.', '')
Message.query.filter(needle==query_term.strip()).one()
But problem with this is that there can be many special characters in db like "! ; : ? &" etc and needle will look very inefficient so please suggest me any efficient solution to avoid repeating func.replace function.
I cannot find same question on stackoverflow let me know if someone has already answered it.