Late last year I came across the same problem. These are the two methods I found that worked.
#include <Array.au3>
Local $Paths = 'C:\Users\' & @CRLF & _
'C:\EEC (1)\someother file' & @CRLF & _
'C:\MSfree\' & @CRLF & _
'C:\EEC (1)\'
Local $sSearch = "C:\EEC"
; --------------------- Method 1 ----------------------------------
; Check if "\E" is in $sSearch. If "\E" is present, replace "\E" with "\E\\E\Q", because of the "\Q" & $sSearch & "\E" in RE pattern.
Local $sSearchA = (StringInStr($sSearch, "\E") ? StringReplace($sSearch, "\E", "\E\\E\Q") : $sSearch)
;ConsoleWrite("\Q" & $sSearchA & "\E" & @CRLF)
Local $a = StringRegExp($Paths, "(\Q" & $sSearchA & "\E.*)", 3)
_ArraySort($a)
;_ArrayDisplay($a)
If UBound($a) > 1 Then
For $i = 1 To UBound($a) - 1 ; Keep $a1[0]
$sSearchB = (StringInStr($a[$i], "\E") ? StringReplace($a[$i], "\E", "\E\\E\Q") : $a[$i])
ConsoleWrite("\Q" & $sSearchB & "\E" & @CRLF)
Local $sOutput = StringRegExpReplace($Paths, "(\Q" & $sSearchB & "\E\R?)", "")
Next
Else
Local $sOutput = StringRegExpReplace($Paths, "(\Q" & $sSearchA & "\E.*\R?)", "")
EndIf
MsgBox(0, "\Q...\E", $sOutput)
; Or
; --------------------- Method 2 ----------------------------------
; Beware "(1)", where (n) tests whether the capturing group with absolute number n matched.
$sSearch = StringRegExpReplace($sSearch, "([\\()\.^$|\[\]{}*+?#])", "\\$1")
;ConsoleWrite($sSearch & @CRLF)
Local $a1 = StringRegExp($Paths, "(" & $sSearch & ".*)", 3)
_ArraySort($a1)
;_ArrayDisplay($a1)
If UBound($a1) > 1 Then
For $i = 1 To UBound($a1) - 1 ; Keep $a1[0]
$sSearchC = StringRegExpReplace($a1[$i], "([\\()\.^$|\[\]{}*+?#])", "\\$1")
ConsoleWrite($sSearchC & @CRLF)
Local $sOutput = StringRegExpReplace($Paths, "(" & $sSearchC & "\R?)", "")
Next
Else
Local $sOutput = StringRegExpReplace($Paths, "(" & $sSearch & ".*\R?)", "")
EndIf
MsgBox(0, "\\,(,)", $sOutput)
#cs ; Both methods return:-
C:\Users\
C:\MSfree\
C:\EEC (1)\
#ce