如何在asp经典中提取短划线( - )和点(。)之间的字符串

时间:2016-11-07 04:05:10

标签: vbscript asp-classic

有人可以帮我在ASP classic的最后一个URL中提取短划线( - )和点(。)之间的字符串吗?

例如:

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

如何提取3256值?
PS:URL中有许多短划线和一些数字。

2 个答案:

答案 0 :(得分:1)

如果您在数字之前肯定有破折号,则此方法有效。如果你有一个/之前的数字,那么为/ into - 。添加另一个替换。

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

答案 1 :(得分:0)

解决! 我找到了答案:

getBadger() {

    var link = 'https://graph.facebook.com/1650393515218783? fields=posts&access_token=EAAN3TCkzCxsBACdSQIu3KDiORivp0eEeQWNMBu1aT8TnEWYEqQhblcl4IZA$

    this.http.get(link).subscribe(data => { this.data = data; this.posts = JSON.parse(data._body); });