以下是一些数据示例:
1|Toy Story (1995)|01-Jan-1995||http://us.imdb.com/M/title-exact?Toy%20Story%20(1995)|0|0|0|1|1|1|0|0|0|0|0|0|0|0|0|0|0|0|0
2|GoldenEye (1995)|01-Jan-1995||http://us.imdb.com/M/title-exact?GoldenEye%20(1995)|0|1|1|0|0|0|0|0|0|0|0|0|0|0|0|0|1|0|0
我希望用年份提取电影名称:
Toy Story (1995)
GoldenEye (1995)
非常感谢!
答案 0 :(得分:2)
似乎是管道(|
) - 分开的数据,所以
df <- read.table(sep = "|", text="
1|Toy Story (1995)|01-Jan-1995||http://us.imdb.com/M/title-exact?Toy%20Story%20(1995)|0|0|0|1|1|1|0|0|0|0|0|0|0|0|0|0|0|0|0
2|GoldenEye (1995)|01-Jan-1995||http://us.imdb.com/M/title-exact?GoldenEye%20(1995)|0|1|1|0|0|0|0|0|0|0|0|0|0|0|0|0|1|0|0")
然后选择第二列:
df[, 2]
# [1] Toy Story (1995) GoldenEye (1995)
# Levels: GoldenEye (1995) Toy Story (1995)
答案 1 :(得分:1)
在Java中,使用String.split
:
String str = "1|Toy Story (1995)|01-Jan-1995||http://us.imdb.com/M/title-exact?Toy%20Story%20(1995)|0|0|0|1|1|1|0|0|0|0|0|0|0|0|0|0|0|0|0";
String movieName = str.split("\\|")[1];