java - IMDB 数据库的正则表达式

标签 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)

最佳答案

这样就可以了

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

在 Java 中,尝试

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

关于java - IMDB 数据库的正则表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27477286/

相关文章:

java - 带 For 循环获胜者的 TicTacToe 代码...为什么找不到获胜者?

java - 在spring拦截器中获取请求映射对象,获取实际的url字符串模式

java - HSQL + Hibernate 预期异常 : Wrong column type: Found: double,: float

java - 打印格式化数组

c# - Regex.Replace在不同场景下的使用方法

java - 字符串的正则表达式模式至少 4 个字符,在字符串末尾包含特定字符

java - 将 TextView 转换为超链接

regex - sed linux 命令无法插入行

ruby - Ruby 正则表达式是否有像 Perl 中的 "!~"这样的不匹配运算符?

java - 数字正则表达式不匹配