user5471528 user5471528 - 2 years ago 62
Javascript Question

How do I get an array of substrings from an array of strings?

I have an array of string like:

var myArray=['rwt-cable1','rwt-cable42','rwt-cable40',...]

But what I am really interested in is:


What would be the best way? I'm currently looping through items and extract substrings to get my output array.

Answer Source

Simpler would be

var myArray=['rwt-cable1','rwt-cable42','rwt-cable40']>x.replace('rwt-',''));
//["cable1", "cable42", "cable40"]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download