我想对以下语句使用正则表达式:
< destination?
对于上述情况,我该如何编写正则表达式?首先,它检测用户是否想要“顶部”或“底部”目的地,然后检查数量,即10、7或5?
我正在尝试以下不起作用的方法。
(?<top>\d{2})
(?<bottom>\d{2})
基本上,这个想法是如果用户输入前10个目的地,系统将触发响应,例如
console.log("you want top 10 destinations")
发布于 2018-06-04 03:47:42
您可以使用以下正则表达式
.*((?:top|bottom)\s+\d+).*
并将其替换为下面的句子
You want the $1 destinations
https://stackoverflow.com/questions/50670299
复制相似问题