如何提取破折号(-)和点(.)之间的字符串在asp经典



有没有人能帮我在ASP经典URL的最后提取破划线(-)和点(.)之间的字符串?

例如:

mypizza.com/this-is-my-special-6-pizza-this-week-3256.html

如何提取3256值?
PS: URL中出现了很多破折号和一些数字

如果数字前有破折号,则此操作有效。如果数字前可以有/,则在-中添加另一个/。

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)

最新更新