ci.jpl: Support multiple spaces in string of filter groups

To avoid the unexpected error when there are multiple spaces between
config group names, improve the replace logic to filter config groups.

Also, extra spaces at the beginning and end of the string of filter
groups can also be supported by this patch.

Signed-off-by: Xinyu Zhang <xinyu.zhang@arm.com>
Change-Id: Icbb2812f70ebab6418765acbe508cf43929abf98
diff --git a/jenkins/ci.jpl b/jenkins/ci.jpl
index 2a4d751..1848229 100644
--- a/jenkins/ci.jpl
+++ b/jenkins/ci.jpl
@@ -56,9 +56,16 @@
 }
 
 def listConfigs(config_list, filter_group) {
+  // In case filter group starts with spaces
+  config_groups = filter_group.replaceAll(/^\s+/, '')
+  // In case filter group ends with spaces
+  config_groups = config_groups.replaceAll(/\s+$/, '')
+  // Replace spaces between config group names with ' -g '
+  config_groups = config_groups.replaceAll(/\s+/, " -g ")
+
   def build_config_list_raw = sh(script:
     """
-    python3 ./tf-m-ci-scripts/configs.py -g ${filter_group.replace(" ", " -g ")}\n
+    python3 ./tf-m-ci-scripts/configs.py -g ${config_groups}\n
     """, returnStdout: true).trim()
   def build_config_list = build_config_list_raw.tokenize('\n')
   config_list.addAll(build_config_list)