var someString = '_asd_nsdn_guadgu_12', parts = someString.match(/_?([^_]+_)+|[^_]+/g); alert(parts.join('\n'));