Reputation: 13
I need it to detect something like
STEAM_numberhere 0 to 5:numberhere only 0 or 1:any number here
PHP preg_match
Thanks for your help!
STEAM_X:Y:Z
X has to be 0, 1, 2, 3, 4 or 5
Y has to be either 0 or 1
Z can be any number, just can't contain any text.
Valid: STEAM_0:1:1958281
Invalid: STEAM_9:4:1912tg
Upvotes: 1
Views: 115
Reputation: 19380
preg_match("#STEAM_[0-5]{1}:[0-1]{1}:([0-9]+)#", $string, $matches);
Something like this, haven't tested it.
Tested:
$string = "STEAM_0:1:1928519 STEAM_1:5:19a28519 STEAM_18:1:1928519x";
preg_match("#STEAM_[0-5]{1}:[0-1]{1}:([0-9]+)#", $string, $matches);
echo($matches[0]); //STEAM_0:1:1928519
Upvotes: 0