Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
对于一个网站,我想只允许使用正则表达式的圆括号之间的生产年份。
允许:
Movie 1 (2010)
不允许:
Movie 2 (2010 English) Movie 2 (01-01-2010)
我想要的是一个正则表达式,它将检测字母何时在括号之间或字母、空格和数字的组合。
我如何实现这一目标?
就像是
/^.+\(\d{4}\)$/
这应该做得很好:
/\(.*?([0-9]{4}).*?\)/
然后,您可以使用$1来检索年份。
$1