Get first part of string up to some string, that may or may not be in it
I've got the following strings:
Showname Showname - with hyphen Showname - Season 4 开发者_开发技巧
What I want is:
Showname Showname - with hyphen Showname
What I've come up with so far is:
/(.*)( - season /d/d?)/i
But that requires - season ??
to be in the string, which is not always the case...
Any help would be really appreciated!
Cheers,
Roybasically, you want to strip off the season?
do a regex replace on
/ - season \d+$/i
and replace it with an empty string.
if the season isn't in there, nothing will get replaced and the original string will be returned.
精彩评论