我的链接名称以日期结尾,我需要点击带有qtp的webtable中最新日期的链接,日期格式如“2000-10-16”
示例链接名称:
30000-1-xxxxxxxx 2000-10-16.xls
30000-1-xxxxxxxx 2008-10-16.xls
30000-1-xxxxxxxx 2014-01-11.xls
我该怎么做?
答案 0 :(得分:0)
您必须格式化新日期并使用新日期替换源字符串中的旧日期:
>> s = "30000-1-xxxxxxxx 2000-10-16.xls"
>> d = Date
>> d = Join(Array(Year(d), Right(100 + Month(d), 2), Right(100 + Day(d), 2)), "-")
>> WScript.Echo d
>> set r = New RegExp
>> r.Pattern = "\d{4}-\d{2}-\d{2}"
>> t = r.Replace(s, d)
>> WScript.Echo t
>>
2014-01-23
30000-1-xxxxxxxx 2014-01-23.xls