IMDB数据库的正则表达式

时间:2014-12-15 04:18:21

标签: java regex

我是一名基本编码员,对正则表达式来说非常新。我需要将下面的输入过滤到下面指定的输出,我需要它作为我的分配任务的输入。任何人都可以帮我写单独的正则表达式或至少是指导吗?还有其他方法可以做到这一点吗?

输入:

A Gathering of Eagles (1963)  (uncredited)  [Mrs. Josten]           
The Creed of Violence (????)  (rumored) 
A Life of Her Own (1950)  (uncredited)  [Model]         
Pourvu qu'elles soient douces (Libertine II) (1989)  [William]  <6>
A Virgin in Hollywood (1953)  [Darla Sloan]  <1>            
Gordon-Levitt, Joseph   (500) Days of Summer (2009)
Aaron Slick from Punkin Crick (1952)  (uncredited)  [Showgirl]      
Cruisin (On a Saturday Night) (2009) {{SUSPENDED}}  [Officer Hernandez]
Angels in Disguise (1949)  (uncredited)  [Reception Nurse]          
The Candid Camera Story (Very Candid) of the Metro-Goldwyn-Mayer Pictures 1937 Convention (1937)  (uncredited)  [Himself]
Annie Get Your Gun (1950)  (uncredited)  [Carriage Woman]   
From the Ashes (2011/I)  (voice)  [Himself - Narrator]      
Bachelor in Paradise (1961)  (uncredited)  [Minor Role]
The Deep Blue Goodbye (????)  (rumored)  [Travis McGee]
Southpaw (????)  (uncredited)  [Spectator/High Roller]

输出

A Gathering of Eagles (1963)
A Life of Her Own (1950)
Pourvu qu'elles soient douces (Libertine II) (1989)
A Virgin in Hollywood (1953)
Gordon-Levitt, Joseph   (500) Days of Summer (2009)
Aaron Slick from Punkin Crick (1952)
Cruisin (On a Saturday Night) (2009)
Angels in Disguise (1949)
The Candid Camera Story (Very Candid) of the Metro-Goldwyn-Mayer Pictures 1937 Convention (1937)
Annie Get Your Gun (1950)
From the Ashes (2011/I)
Bachelor in Paradise (1961)

1 个答案:

答案 0 :(得分:1)

这应该做到

^.*?\(\d\d\d\d.*?\)

在Java中,试试

Pattern.compile("^.*?\\(\\d\\d\\d\\d.*?\\)", Pattern.MULTILINE)