Reputation: 858
i am trying to get this
string = 'Boss S02E06 more string'
i want S02E06
out of the complete string . and if possible split the string there.
Please note that the values after S and E in that keep changing so its not constant .
But im not expert when it comes to it.But i guess its time to start learning.
Thanks guys
Upvotes: 1
Views: 73
Reputation: 15338
try this:
$string = "Boss S02E06 more string";
preg_match(`.*(S\d+E\d+).*`,$string,$match);
echo $match[0];// it will echo S02E06
Upvotes: 1
Reputation: 490413
You would use a Regular Expression. You can learn them here.
PHP has preg_match()
, which is what you would use.
The regex to match would be something like S\d+E\d+
. If you want the values, use a capturing group.
It's up to you to put all these ideas together to arrive at an answer.
Upvotes: 0