Improved regex matching for prefix filter