【发布时间】:2020-10-08 06:49:53
【问题描述】:
我必须将文本与正则表达式模板匹配。 示例如下:
templates = {"x":"welcome {1}, how can I help you","y":"hi {1},here is your concern {2}"}
input_text = "welcome john, how can I help you" # for this output should be "x"
input_text = "Hi john,here is your concern sick leave"# for this output shoud be "y"
input_text = "Welcome john, how can I help you, how are you?" # for this output should be None
input_text = "can I know your name" # for this output should be None
您能否提供一些意见来解决这个问题? 提前致谢。
【问题讨论】:
-
您提出了一个问题,并且真诚地有人花时间和精力来回答您的问题。你已经接受了他们的回答,所以我认为这对你有帮助。请不要破坏您的问题,因为这对帮助过您的人非常不尊重。