admin管理员组文章数量:1023585
I have content in a meta tag.
<meta property="video" content="initialver=1.0" />
I get the content in this tag using getAttribute("content")
. Then I have a string: initialver=1.0
. My need is getting "1.0". How can I do this without using split()
?
I have content in a meta tag.
<meta property="video" content="initialver=1.0" />
I get the content in this tag using getAttribute("content")
. Then I have a string: initialver=1.0
. My need is getting "1.0". How can I do this without using split()
?
2 Answers
Reset to default 1var str = "initialver=1.0";
var result = str.substring(11);
You can use regex and match to do this
var x = "initialver=1.0".match(/\d+$|\d+\.\d+$/)[0]
I have content in a meta tag.
<meta property="video" content="initialver=1.0" />
I get the content in this tag using getAttribute("content")
. Then I have a string: initialver=1.0
. My need is getting "1.0". How can I do this without using split()
?
I have content in a meta tag.
<meta property="video" content="initialver=1.0" />
I get the content in this tag using getAttribute("content")
. Then I have a string: initialver=1.0
. My need is getting "1.0". How can I do this without using split()
?
2 Answers
Reset to default 1var str = "initialver=1.0";
var result = str.substring(11);
You can use regex and match to do this
var x = "initialver=1.0".match(/\d+$|\d+\.\d+$/)[0]
本文标签: htmlWhat is an alternative to using split() on a string in JavaScriptStack Overflow
版权声明:本文标题:html - What is an alternative to using split() on a string in JavaScript? - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745539362a2155110.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论