<?php
$strings = [
"cricket-ck-game-play",
"hand-ball-hb-game-play",
"volley-ball-vb-game-play",
"soccer-sc-game-play"
];
$pattern = "/\b(\w{3,}(?:-(?:\w{3,}))*)-(\w{2})-game-play\b/";
foreach ($strings as $str) {
preg_match($pattern, $str, $matches);
print_r($matches);
}
- Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.31, 8.2.0 - 8.2.27, 8.3.0 - 8.3.15, 8.4.1 - 8.4.2
- Array
(
[0] => cricket-ck-game-play
[1] => cricket
[2] => ck
)
Array
(
[0] => hand-ball-hb-game-play
[1] => hand-ball
[2] => hb
)
Array
(
[0] => volley-ball-vb-game-play
[1] => volley-ball
[2] => vb
)
Array
(
[0] => soccer-sc-game-play
[1] => soccer
[2] => sc
)
preferences:
129.01 ms | 408 KiB | 5 Q