I am trying to take a string such as
Results where srn.firsttname like 'Chicken%' and coalesce(sri.DocumentType_id,0) not in (71, 72, 70, 69) and having srn.lastname like 'Alfredo%'
to return
Results where srn.lastname like 'Chicken%' and srn.firstname like 'Alfredo%'
using regex? I haven't found anything online to assist with this.
This is the code I have that is not regex:
function stringSlicer(userInput) {
    var frontStringLength = 0;
    var middlecut = 1;
    var slicer = 0;
    for (var i = 0; i < userInput.length; i++) {
        if (userInput.substring(i, 1) === "(") {
            frontStringLength = i - 13;
            break;
         }
    }
    for (var j = 0; j < userInput.length; j++) {
        if (userInput.substring(j, 1) !== ")") {
            middlecut += 1;
        }
        else if (userInput.substring(j, 1) === ")") {
            middlecut += 1;
            slicer += 1;
            if (slicer === 2) {
                break;
            }
        }
    }
    var result = userInput.substring(0, frontStringLength) +     userInput.substring(frontStringLength + middlecut);
    return result;
}
Thanks!!
 
     
     
     
    