开发者

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,

Roy


basically, 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜