在变量空白和固定字符串之间的数字上进行preg_match


preg_match on a number between variable whitespace and a fixed string

我正试图想出一个正则表达式,该表达式将符合以下字符串中的25

Always       -       25 (Lifetime

-25之间的空间量可以是可变的,但后面的(Lifetime将始终存在。

我试过这个:preg_match('/'s(.*)'s'(Lifetime',$sString,$aMatch);,但它符合25及其之前的所有内容。

尝试以下操作:

preg_match('~'s+('d+)'s'(Lifetime~', $sString, $aMatch);

它匹配一个或多个空格字符,后跟一个数字,最后是(Lifetime字符串。