Get Substring between two characters using javascript
You can try this
var mySubString = str.substring( str.indexOf(":") + 1, str.lastIndexOf(";"));
You can also try this:
var str = 'one:two;three'; str.split(':').pop().split(';')[0]; // returns 'two'
Use split()
var s = 'MyLongString:StringIWant;';var arrStr = s.split(/[:;]/);alert(arrStr);
arrStr
will contain all the string delimited by :
or ;
So access every string through for-loop
for(var i=0; i<arrStr.length; i++) alert(arrStr[i]);