From 0968d0929684772d428e67f09630e87f3fda73ba Mon Sep 17 00:00:00 2001 From: Daishan Peng Date: Fri, 3 Aug 2018 15:55:23 -0700 Subject: [PATCH] fix regular expression https://github.com/rancher/rancher/issues/14939. Problems: we are not using lazy match to match the group (!=|=) so that "foo != bar` can be parsed wrongly as (foo !) (=) (bar). Solutions: Use lazy match to match as less as possible the characters in the first group. Also improved the whitespace matches. --- mapper/scheduling.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mapper/scheduling.go b/mapper/scheduling.go index 657d284b..3cccd096 100644 --- a/mapper/scheduling.go +++ b/mapper/scheduling.go @@ -14,7 +14,7 @@ import ( ) var ( - exprRegexp = regexp.MustCompile("^(.*)(=|!=|<|>| in | notin )(.*)$") + exprRegexp = regexp.MustCompile("^(.*?)\\s*(=|!=|<|>|in|notin)\\s*(.*)$") ) type SchedulingMapper struct {