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

javascript - jQuery Split where numeric number occur - Stack Overflow

programmeradmin4浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论