【发布时间】:2013-05-15 04:19:53
【问题描述】:
好的,我仍在学习 Regex,我正在为我的手机制作语音助手,我希望它接受以下任何一项:
set the timer for 5 minutes
set timer for 5 minutes
set a timer for 5 minutes
set a goddamn timer for 5 minutes
set this timer for 5 minutes
基本上我想要set 和timer 之间的每一个字。
我正在尝试,但它不起作用。
set (the|a|.) timer for [1-9]{1,} (minute|minutes)
另一个命令是关于取消定时器:
cancel the timer
timer cancel
cancel timer
基本上,如果“取消”和“计时器”这两个词在句子中以任意组合出现,它应该取消计时器。
任何帮助将不胜感激。
【问题讨论】:
-
enjoy :)
-
谢谢,该网站有一些不错的功能。
-
不客气,注意网站使用的是PHP的PCRE实现,所以你得看看你的regex flavor和PHP PCRE的区别