how can i remove chars between indexes in a javascript string -


i have following:

var s="hi how you"; var bindex = 2; var eindex = 6; 

how can remove chars s reside between bindex , eindex?
therefore s "hi you"

first find substring of string replace, replace first occurrence of string empty string.

s = s.replace(s.substring(bindex, eindex), ""); 

another way convert string array, splice out unwanted part , convert string again.

var result = s.split(''); result.splice(bindex, eindex - bindex); s = result.join(''); 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -