Currently have a regex rule
You may use an optional group around
\?.* and make the
? obligatory inside it and add an end of string
See the regex demo
^- start of string
\/connect- a literal substring
(?:\?.*)?- an optional group that matches 1 or 0 sequences of:
\?- a literal
.*- zero or more characters other than newline, as many as possible up to...
$- end of string.