【发布时间】:2016-11-07 23:35:02
【问题描述】:
有人可以帮我提取 ASP Classic 中 URL 末尾的破折号 (-) 和点 (.) 之间的字符串吗?
例如:
mypizza.com/this-is-my-special-6-pizza-this-week-3256.html
如何提取3256 值?
PS:URL中有很多破折号和一些数字。
【问题讨论】:
标签: vbscript asp-classic
有人可以帮我提取 ASP Classic 中 URL 末尾的破折号 (-) 和点 (.) 之间的字符串吗?
例如:
mypizza.com/this-is-my-special-6-pizza-this-week-3256.html
如何提取3256 值?
PS:URL中有很多破折号和一些数字。
【问题讨论】:
标签: vbscript asp-classic
如果您在数字前肯定有破折号,则此方法有效。如果你可以在数字之前有一个 /,那么在 - 中添加另一个替换 /。
dim s, aSplit
s = "mypizza.com/this-is-my-special-6-pizza-this-week-3256.html"
s = replace(s, ".", "-") ' replace any dots with dashes
aSplit = split(s, "-") ' break s into an array, splitting at dashes. Note it is a zero-based array.
dim sOut
sOut = aSplit(ubound(aSplit) - 1) ' get the penultimate entry in the array
【讨论】:
解决了! 我找到了答案:
Dim n, strPost
dashCount = len(urlPost)-len(replace(urlPost,"-",""))
n=dashCount
thisURL=split(urlPost,"-")
strPost=replace(thisURL(n),".html","")
response.write(strPost)
【讨论】: