'How to create python regex to match only if at least 3 defined words are exist and allow other random words as well?

Here is my example:

re.compile("({tables}) ({middle})  ({end})"format(tables=config.kvkk_tables,middle=config.middle_sentence,end=config.end_of_sentence),re.IGNORECASE))

One of tables, middle and end string must be in sentence. When this condition matched we do not want to check any other things allow any random words and characters.

tables = "oms.claim|oms.order"

middle = "request|requested"

end = "respond|responded|answer|answered"

First Example:(Example needs to be matched) since there are at least 1 word from tables, middle and end.

"Hello could you please define my username for oms.claim table as it is requested by order department and needs to be answered immediately."

Second Example:(Example needs to be NOT matched) since there are not any word from end string.

"Hi, oms.order table requested from me, could you please help me about that?"

What I tried and failed:

@bolt_app.message(re.compile("({tables}) ({middle} |(:?) {end})".
                         format(tables=config.kvkk_tables,middle=config.middle_sentence,end=config.end_of_sentence),re.IGNORECASE))


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source