str = "%#K%jz0i8t69v29h##K%vr7eoawzff0d##K%yu13m6zlqwwn##K%wuu9jkc54chc##K%kokiwgo9ybff#%"; LinkArr = str.replace(/^.*%#(?=K)|#%$/g,'').split(/##/ig); alert(LinkArr.join(',\n'))