TO ALL 学习下。
On Tue, Oct 20, 2020 at 11:21:46AM +0800, Zhang Yuhang wrote:
info: "/compare_canditates" error, due to fault regular expression
before: /^vm-.*-\d\w*-([a-zA-Z]+)|(\d+)$/ afeter: /^vm-.*-\d\w*-(([a-zA-Z]+)|(\d+))$/
以上是代码的简单重复 去掉
before miss a couple brackets, so will match /\d+$/. It will cause an exception.
该描述的问题,反而模糊和略过了: 你遇到了啥问题, 能贴出错误消息吗? Regex期望匹配的实际的例子, 都有哪些? 其中哪些是之前没法匹配的?
Thanks, Fengguang
Signed-off-by: Zhang Yuhang zhangyuhang25@huawei.com
src/lib/web_backend.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/lib/web_backend.rb b/src/lib/web_backend.rb index 48cfadb..fda01ca 100644 --- a/src/lib/web_backend.rb +++ b/src/lib/web_backend.rb @@ -47,7 +47,7 @@ end def filter_tbox_group(es_result) result = Set.new es_result.each do |r|
- if r =~ /(^.+--.+$)|(^vm-.*-\d\w*-([a-zA-Z]+)|(\d+)$)/
- if r =~ /(^.+--.+$)|(^vm-.*-\d\w*-(([a-zA-Z]+)|(\d+))$)/ index = r.index('--') || r.rindex('-') r = r[0, index] end
-- 2.23.0