开发者

Allow only numbers/year between rounded brackets

For a website I want to allow only the year of product开发者_如何学Cion between rounded brackets with a RegEx.

Allowed:

Movie 1 (2010)

Disallowed:

Movie 2 (2010 English)

Movie 2 (01-01-2010)

What I want is a RegEx that will detect when letters are between the brackets or a combination of letters, spaces and numbers.

How do I achieve this?


Something like

/^.+\(\d{4}\)$/


This should do just fine:

/\(.*?([0-9]{4}).*?\)/

You can then use $1 to retrieve the year.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜