admin管理员组

文章数量:1426197

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.

本文标签: javascriptjQuery Split where numeric number occurStack Overflow