Search code examples
javascriptjslint

jslint Expected ']' and instead saw '/'


I am getting the exception like

jslint Expected ']' and instead saw '/'.

function returnFilePath(fullPath) {
    var objRE = new RegExp(/([^//]+)\\/);
    var stringPath = objRE.exec(fullPath);
    if (stringPath == null) {
        return null;
    }
    else {
        return stringPath[1];
    }
}

Not able to find the solution for this.


Solution

  • Seems your regex is invalid: enter image description here (Screenshot from: https://regex101.com/)

    What pattern are you trying to match? Could it be:

    ([^\/]+)\\