I want to extract two values from some URLs.
Example URLs:
cricket-ck-game-playhand-ball-hb-game-playvolley-ball-vb-game-playsoccer-sc-game-play
I want extract the full game name and its short name separately ignoring the -game-play part at the end of the URL.
I've tried the following code which returns 'ck', 'hb', 'vb', 'sc', but not the full name.
preg_match("/(?<=-)[^-]*(?=-game-play)/", $uri, $game);
Actual results I am getting:
array(1) {
[0]=>
string(2) "ck"
}
Expected Results:
case:1 (In case of example 1) - array(2) {
[0]=>
string(7) "cricket"
[1]=>
string(2) "ck"
}
case:2 (In case of example 2) - array(2) {
[0]=>
string(9) "hand-ball"
[1]=>
string(2) "hb"
}
cketc always more than 2 chars and are the short names always 2 chars? Are they always characters a-z?