gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 06:20:17 24 4
gpt4 key购买 nike

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

输入:

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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com