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

I have content in a meta tag.<meta property="video" content="initialver=1.0" &g

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]

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745539363a4632055.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信