javascript - jQuery Split where numeric number occur - Stack Overflow

I have a stringlike this-is-my-0-string.this-is-my-new-1-string-occur.i want to break string where n

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
Add a ment  | 

1 Answer 1

Reset to default 8

It'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

相关推荐

  • javascript - jQuery Split where numeric number occur - Stack Overflow

    I have a stringlike this-is-my-0-string.this-is-my-new-1-string-occur.i want to break string where n

    3小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

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

关注微信