通过 JavaScript 提取字符串的特定部分
我目前正在为一个项目搞乱 tumblr API。
我似乎遇到的问题是我必须能够从 src url 中提取用户名,例如
http://(you).tumblr.com/api/read/json
我考虑使用类似 substr()
的东西,但我不能保证要提取的字符数。
有什么想法吗?
I'm currently messing with the tumblr API for a project.
The problem I seem to have is I have to be able to extract the username from the src url e.g.
http://(you).tumblr.com/api/read/json
I looked into using something like substr()
but I can't guarantee the number of characters to extract.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

使用正则表达式:
简而言之:
将计算为
详细说明:
using the regular expression:
in short:
will evaluate to
to elaborate: