Reputation: 17681
I'm trying to come up with a regular expression that will qualify on the 25
in this string:
Always - 25 (Lifetime
The amount of space between the -
and the 25
can be variable, but the trailing (Lifetime
will always be there.
I've tried this: preg_match('/\s(.*)\s\(Lifetime',$sString,$aMatch);
but it qualifies on the 25
and everything preceding it.
Upvotes: 2
Views: 381
Reputation: 3330
Try the following:
preg_match('~\s+(\d+)\s\(Lifetime~', $sString, $aMatch);
It matches one or more space characters, followed by a number and finally the (Lifetime
string.
Upvotes: 4