鉴于/foo/bar/image.jpg?x=1&y=2
,我如何获得image.jpg
?
https://stackoverflow.com/a/423385提供了部分答案,但未解决GET参数。
答案 0 :(得分:4)
您可以像其他人建议的那样使用正则表达式,但我觉得这更具可读性:
TimeSpan ts = DateTime.Now.TimeOfDay;
List<DateTime> lstdt = dates.Where(d => d.Date == tpl.Item1).ToList();
lstdt.ForEach(d => d = d.Date + ts);
答案 1 :(得分:2)
既然?符号将URL与GET参数分开,您可以
VisualState
答案 2 :(得分:1)
尝试:
var fileName = str.split('/').slice(-1)[0].match(/[^?]+/)[0];
或者,对于正则表达式方法:
>> [Q,R] = qr(A')
Q =
-0.4918 0.2143 -0.6131 -0.5675 -0.1086 0.0503
-0.5468 0.0638 0.0596 0.5238 -0.5922 -0.2614
-0.0767 -0.6389 -0.1919 -0.0733 0.2275 -0.7014
-0.5514 -0.2397 0.6743 -0.3550 0.1568 0.1821
-0.3818 0.2094 -0.1834 0.4750 0.7368 0.0904
-0.0589 -0.6637 -0.3090 0.2158 -0.1351 0.6291
R =
-1.6565 -1.1588 -1.0907 -1.3634
0 -1.3597 -0.8286 -0.6385
0 0 -0.9760 -0.9745
0 0 0 0.5972
0 0 0 0
0 0 0 0
>> Q*(R'\b)
ans =
-0.4256
-0.3057
0.3568
-0.2745
-0.2823
0.4249
>>
答案 3 :(得分:1)
您可以使用此正则表达式:
/\/([^?\/]+(?=\?|$))/
并使用捕获的grpup#1。
/ # matches a literal /
[^?\/]+ # matches 1 or more of any char that is not ? or /
(?=\?|$) # is a lookahead to assert that next position is ? or end of line