+(defun ivy--regex-ignore-order (str)
+ "Re-build regex from STR by splitting at spaces.
+Ignore the order of each group. Everything before \"!\" should
+match. Everything after \"!\" should not match."
+ (let ((parts (split-string str "!" t)))
+ (cl-case (length parts)
+ (0
+ "")
+ (1
+ (if (string= (substring str 0 1) "!")
+ (list (cons "" t)
+ (ivy--regex-ignore-order--part (car parts) t))
+ (ivy--regex-ignore-order--part (car parts))))
+ (2
+ (append
+ (ivy--regex-ignore-order--part (car parts))
+ (ivy--regex-ignore-order--part (cadr parts) t)))
+ (t (error "Unexpected: use only one !")))))
+