var str = [' - Learn _ in - 111', 'x - Learn x in - 22', 'xyz - Learn xyz in - 3', '44444']; for (i in str) { s = str[i].match(/^(?:[^\s-]*?)([^\s-])?(?:[\s-]+)(.+)$/); s && alert(JSON.stringify('1: ' + s[1] + ', 2: ' + s[2])); }