var reg = /\b(?=(?:OR|AND)\b)/ig; var string = 't.id = 10 OR t.name = "user" AND user.account = 0'; alert(string.split(reg).join('\n'));