【发布时间】:2012-12-28 05:41:57
【问题描述】:
我似乎不知道如何从Rogue Assassin 2007 中取出年份并返回:
moviename = "Rogue Assassin" 'Whitespace doesn't matter
movieyear = "2007" 'Whitespace doesn't matter
但是,我无法让它工作。我一直在尝试以下方法:
If System.Text.RegularExpressions.Regex.IsMatch(fn, "[0-9][0-9][0-9][0-9]") Then 'Is this right?
Dim mtemp As String() = fn.Split(" ") 'Movie temp array
myear(0) = mtemp.Last 'Attempting to set year to the last split
For Each z As String In mtemp 'Adding the other elements in mtemp together to remake the title
If z IsNot mtemp.Last Then
mtitle(0) = z & " " 'Movie title
Else
Exit For
End If
Next
...
Else
...
End If
非常感谢任何帮助!
【问题讨论】:
-
你总是保证名字中有年份吗?年份总是四个字符还是两个字符?您是否能够预先格式化年份值以使其更易于识别?
-
这只是大约 5 个 if 语句的一部分...前 2 个是大括号中的年份,方括号中的年份,然后是这个,然后如果年份是目录名称,那么最后,仅搜索标题。