sqlmapproject/sqlmap · error · SqlmapSyntaxException

invalid regular expression

Error message

invalid regular expression '%s' ('%s')

What it means

Startup value-validation guard in _basicOptionValidation: the pattern given to --regexp (conf.regexp) is compiled with re.compile inside a try/except; any re error (bad syntax, unbalanced brackets, invalid escapes) raises SqlmapSyntaxException with the pattern and the underlying error string via getSafeExString. Same guard applies to --retry-on, --crawl-exclude and --scope regexes nearby.

Solutions

  1. Fix the regex syntax (check brackets, quantifiers, escapes)
  2. Test the pattern in a standalone Python re.compile before rerunning
  3. Simplify to a plain --string match if a literal suffices
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at lib/core/option.py:2917 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of sqlmapproject/sqlmap@0a35b20e39 (2026-08-26). Data as JSON: /api/errors/2e5b884471af2b09. Report an issue: GitHub.

Appendix: source

Thrown at lib/core/option.py:2917

    if conf.dumpAll and conf.search:
        errMsg = "switch '--dump-all' is incompatible with switch '--search'"
        raise SqlmapSyntaxException(errMsg)

    if conf.string and conf.notString:
        errMsg = "option '--string' is incompatible with switch '--not-string'"
        raise SqlmapSyntaxException(errMsg)

    if conf.regexp and conf.nullConnection:
        errMsg = "option '--regexp' is incompatible with switch '--null-connection'"
        raise SqlmapSyntaxException(errMsg)

    if conf.regexp:
        try:
            re.compile(conf.regexp)
        except Exception as ex:
            errMsg = "invalid regular expression '%s' ('%s')" % (conf.regexp, getSafeExString(ex))
            raise SqlmapSyntaxException(errMsg)

    if conf.paramExclude:
        if re.search(r"\A\w+,", conf.paramExclude):
            conf.paramExclude = r"\A(%s)\Z" % ('|'.join(re.escape(_).strip() for _ in conf.paramExclude.split(',')))

        try:
            re.compile(conf.paramExclude)
        except Exception as ex:
            errMsg = "invalid regular expression '%s' ('%s')" % (conf.paramExclude, getSafeExString(ex))
            raise SqlmapSyntaxException(errMsg)

    if conf.retryOn:
        try:
            re.compile(conf.retryOn)
        except Exception as ex:
            errMsg = "invalid regular expression '%s' ('%s')" % (conf.retryOn, getSafeExString(ex))
            raise SqlmapSyntaxException(errMsg)

View on GitHub (pinned to 0a35b20e39)