最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

html - What is an alternative to using split() on a string in JavaScript? - Stack Overflow

programmeradmin2浏览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() ?

Share Improve this question edited Mar 23, 2013 at 6:00 ben author 2,9552 gold badges29 silver badges44 bronze badges asked Mar 23, 2013 at 5:00 DjangoDevDjangoDev 9577 gold badges16 silver badges25 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 1
var 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]
发布评论

评论列表(0)

  1. 暂无评论