1

How can I split following string:

1D11M58S

by means of regexp in javascript?

My result should be:

[1D, 11M, 58S]

thanks

1
  • I think I have found it .match( /\d+./g ) Commented Jun 27, 2015 at 21:32

1 Answer 1

1

I would consider matching vs splitting the string:

var r = '1D11M58S'.match(/\d+\D+/g);
console.log(r); //=> [ '1D', '11M', '58S' ]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.