我正在尝试创建与以下内容匹配的正则表达式模式:

Updated x word word


x =是一个数字,例如2

我尝试了以下方法:

(Updated\s\d\s\w\s\w)


例如,我想要:Updated 2 mins ago,以匹配。

但这似乎不起作用:http://regexr.com/3ef05

最佳答案

您需要使用quantifiers来显示数字和单词组可以包含多个字符:

(Updated\s\d+\s\w+\s\w+)


这有效:http://regexr.com/3ef08

09-27 03:05