I have a string like
this-is-my-0-string. this-is-my-new-1-string-occur.
i want to break string where number occurs
like
this-is-my , 0 , string
and this-is-my-new,1, string-occur
in mon words i need to break my string where numbers occur. number is any from 0, 99999 is it possible to do in javascript or jquery ? How to do this
Thanks in advance
I have a string like
this-is-my-0-string. this-is-my-new-1-string-occur.
i want to break string where number occurs
like
this-is-my , 0 , string
and this-is-my-new,1, string-occur
in mon words i need to break my string where numbers occur. number is any from 0, 99999 is it possible to do in javascript or jquery ? How to do this
Thanks in advance
Share Improve this question asked Dec 28, 2012 at 7:20 Hitu BansalHitu Bansal 3,13712 gold badges55 silver badges89 bronze badges 2- i tried simple split function . it doesnot make sense – Hitu Bansal Commented Dec 28, 2012 at 7:23
- You should split with regex. – user1326628 Commented Dec 28, 2012 at 7:34
1 Answer
Reset to default 8It's using split alright.
var string1 = "this-is-my-0-string. this-is-my-new-1-string-occur.";
var parts = string1.split(/-(\d)-/);
alert(parts);
You can play around here.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745413597a4626644.html
评论列表(0条)